如何获取gridView 中的dropDownList 名称?? 如何获取gridView 中的dorpDownList 名称??dropDownList 是gridView中的一模版列!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ((DropDownList)(gridView1.Rows[e.RowIndex].Cells[inedx].FindControl("DropDownList1"))).SelectedValue.ToString().Trim() <asp:TemplateField HeaderText="DropDownList " HeaderStyle-BackColor="#8bb9ee"> <ItemTemplate> <asp:DropDownList ID="DropDownList1" Width="120px" runat="server"></asp:DropDownList> </ItemTemplate> </asp:TemplateField> string y = int.Parse(((DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlDepart")).ClientID); <asp:TemplateField HeaderText="学历"> <ItemTemplate> <%# Eval("xueliText")%> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="DDLXueli" runat="server" Width="90px" /> </EditItemTemplate> <ItemStyle Width="100px" /></asp:TemplateField>string xueli = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DDLXueli")).SelectedValue; string xueli = (GridView1.Rows[e.RowIndex].FindControl("DDLXueli") as DropDownList).SelectedValue; protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { System.Data.DataRowView drv = (System.Data.DataRowView)e.Row.DataItem; RadioButtonList rbl = (RadioButtonList)e.Row.FindControl("txtGender"); if (rbl != null) { if ((bool)drv["Gender"]) { rbl.Items.FindByText("男").Selected = true; } else { rbl.Items.FindByText("女").Selected = true; } } DropDownList ddl = (DropDownList)e.Row.FindControl("txtClassName"); if (ddl != null) { ddl.Items.FindByValue(drv["ClassID"].ToString()).Selected = true; ///这是根据VALUE查找 } } } dorpDownList 名称是指什么? 名称当然是说他的IDstring y = int.Parse(((DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlDepart")).ClientID); 1.当知道每一个DropDownList的Name的时候。string xueli = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList1")).SelectedValue;或者(SelectedItem.Text)2.当不知道DropDownList的Name的时候。 string xueli = ((DropDownList)GridView1.Rows[e.RowIndex].Controls[0]).SelectedValue;或者(SelectedItem.Text) C#封装ocx控件的问题 寻求pet shop数据文档 如何实现包含泛型的构造函数? 在C#中assembly和namespace到底有什么区别? treeview问题(急) 女孩子不该做软件开发吗?郁闷~~· 如何使用泛型集合 检索COM类工厂中CLSID为{00024500-0000-0000-C000-000000000046}的组件时失败,原因是出现以下错误: 8000401a Microsoft Ribbon for WPF 控件问题 求助 c#高级编程 datagridview的问题 WEBFROM如何做界面漂亮,框架合理?
((DropDownList)(gridView1.Rows[e.RowIndex].Cells[inedx].FindControl("DropDownList1"))).SelectedValue.ToString().Trim()
<asp:TemplateField HeaderText="DropDownList " HeaderStyle-BackColor="#8bb9ee">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" Width="120px" runat="server"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="学历">
<ItemTemplate>
<%# Eval("xueliText")%>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="DDLXueli" runat="server" Width="90px" />
</EditItemTemplate>
<ItemStyle Width="100px" />
</asp:TemplateField>
string xueli = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DDLXueli")).SelectedValue;
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
System.Data.DataRowView drv = (System.Data.DataRowView)e.Row.DataItem; RadioButtonList rbl = (RadioButtonList)e.Row.FindControl("txtGender");
if (rbl != null)
{
if ((bool)drv["Gender"])
{
rbl.Items.FindByText("男").Selected = true;
}
else
{
rbl.Items.FindByText("女").Selected = true;
}
} DropDownList ddl = (DropDownList)e.Row.FindControl("txtClassName");
if (ddl != null)
{
ddl.Items.FindByValue(drv["ClassID"].ToString()).Selected = true; ///这是根据VALUE查找
}
}
}
string y = int.Parse(((DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlDepart")).ClientID);
1.当知道每一个DropDownList的Name的时候。
string xueli = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList1")).SelectedValue;或者(SelectedItem.Text)
2.当不知道DropDownList的Name的时候。
string xueli = ((DropDownList)GridView1.Rows[e.RowIndex].Controls[0]).SelectedValue;或者(SelectedItem.Text)