日期:2014-05-17  浏览次数:20392 次

为什么我老是更新不了这个 dropdownlist所在列 的值呢?
C# code

<EditItemTemplate>
<asp:DropDownList ID="ddlPianqu" runat="server" AutoPostBack="true" DataSource='<%# ddlbind()%>' DataValueField="id" DataTextField="pianqu"></asp:DropDownList>
<asp:Label ID="lblPianqu" Text='<%# Bind("pianquid") %>' Visible="false" runat="server"></asp:Label>
</EditItemTemplate>


C# code

protected void GridView1_ItemUpdating(Object sender, GridViewUpdateEventArgs e) 
    {
      ControlParameter cp_id = new ControlParameter("id", TypeCode.String, GridView1.Rows[GridView1.EditIndex].FindControl("lblId").UniqueID.ToString(), "Text");
      ControlParameter cp_salesman = new ControlParameter("salesman", TypeCode.String, GridView1.Rows[GridView1.EditIndex].FindControl("salesmanTextBox").UniqueID.ToString(), "Text");
      ControlParameter cp_pianquid = new ControlParameter("pianquid", TypeCode.String, GridView1.Rows[GridView1.EditIndex].FindControl("ddlPianqu").UniqueID.ToString(),"SelectedValue");
      SqlDataSource1.UpdateParameters.Add(cp_id);
      SqlDataSource1.UpdateParameters.Add(cp_salesman);
      SqlDataSource1.UpdateParameters.Add(cp_pianquid); 
    }


为什么我老是更新不了这个 dropdownlist所在列 的值呢?

------解决方案--------------------
绑定方法是这样DataSource='<%= ddlbind()%>'


------解决方案--------------------
AutoPostBack="false" 再试试