【问题标题】:how to edit gridview fields如何编辑gridview字段
【发布时间】:2013-02-04 19:22:16
【问题描述】:

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

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

        文本框名称 = row.FindControl("Lbl_Name") as TextBox;

        文本框地址 = row.FindControl("Lbl_Address") as TextBox;
        Label mobile = row.FindControl("Lbl_Mobile") as Label;
        Label tele = row.FindControl("Lbl_Tele") as Label;

        标签区域 = row.FindControl("Lbl_Area_ID") as Label;
        标签位置 = row.FindControl("Lbl_Loc_ID") 作为标签;
        标签类别 = row.FindControl("Lbl_Cat_ID") as Label;


        txt_adr.Text = 地址.Text;
        txt_mobile.Text = 手机.Text;
        txt_name.Text = 名称.文本;
        txt_tele.Text = Tele.Text;
        ddl_category.SelectedValue = category.Text;
        // ddloc 的问题
        ddloc.SelectedValue = location.Text;

        DDL_AREA.SelectedValue = area.Text;




    }
}

【问题讨论】:

    标签: asp.net gridview


    【解决方案1】:

    代替

    ddloc.SelectedValue = location.Text;
    

    使用

    ddloc.Selecteditem.Text = location.Text;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-07
      相关资源
      最近更新 更多