62,266
社区成员
发帖
与我相关
我的任务
分享
<asp:TemplateField HeaderText="">
<itemtemplate>
<asp:DropDownList ID="hh" runat="server"></asp:DropDownList>
</itemtemplate>
</asp:TemplateField>
protected void SmartGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList dd = (DropDownList)e.Row.Cells[0].FindControl("hh");
dd.DataSource = DataTable;
dd.DataTextField = "";
dd.DataValueField = "";
dd.DataBind();
}
}
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="city">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataValueField="city" DataTextField="city">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList ddl;
ddl = (DropDownList)(e.Row.FindControl("DropDownList1"));
string sqlstr = "select city from authors";
OledbDataAdapter da=new OledbDataAdapter(sqlstr ,con);
DataSet ds=new DataSet();
da.Fill(ds);
ddl.DataSource=ds;
ddl.DataBind();
}