日期:2014-05-18 浏览次数:20852 次
((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 = (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查找
}
}
}
------解决方案--------------------