我已经在DataGrid EditItemTemplate中创建了一个DropDownList。(手动)
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="nazwa" DataValueField="nazwa"
SelectedValue='<%# Bind("nazwa") %>'>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:baza_pismConnectionString1 %>"
SelectCommand="SELECT [nazwa] FROM [podmioty]"></asp:SqlDataSource>
</EditItemTemplate>如何从后台代码中的下拉列表中获取所选值?
发布于 2013-04-15 18:30:41
我猜你想在编辑过程中找到dropdown的值,下面的代码就行了
protected void gridview1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridViewRow row = gridview1.Rows[e.RowIndex];
DropDownList ddl = row.FindControl("DropDownList1") as DropDownList;
var value=ddl.SelectedValue;
//now do whatever with that value
}https://stackoverflow.com/questions/16012880
复制相似问题