2

我有gridview并且我添加了编辑功能来更新网格内容,因为当用户单击显示带有网格内容的字段的编辑按钮面板时,用户可以编辑具有位置数据的这些数据下拉列表之一的数据。但是当我点击编辑按钮时,所有字段都有网格内容,但 DDL 第一次有第一个项目,当我再次点击编辑时,DDL 有正确的项目。那么它的问题是什么?

 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "editrow")
    {
        GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);

        TextBox name = row.FindControl("Lbl_Name") as TextBox;

        TextBox address = row.FindControl("Lbl_Address") as TextBox;
        Label mobile = row.FindControl("Lbl_Mobile") as Label;
        Label tele = row.FindControl("Lbl_Tele") as Label;

        Label area = row.FindControl("Lbl_Area_ID") as Label;
        Label location = row.FindControl("Lbl_Loc_ID") as Label;
        Label category = row.FindControl("Lbl_Cat_ID") as Label;


        txt_adr.Text = address.Text;
        txt_mobile.Text = mobile.Text;
        txt_name.Text = name.Text;
        txt_tele.Text = tele.Text;
        ddl_category.SelectedValue = category.Text;
        //the problem here on ddloc
        ddloc.SelectedValue = location.Text;

        DDL_AREA.SelectedValue = area.Text;




    }
}
4

1 回答 1

0

代替

ddloc.SelectedValue = location.Text;

利用

ddloc.Selecteditem.Text = location.Text;
于 2013-02-04T11:22:16.950 回答