All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
ASP.NE技巧:GridView绑定DropdownList_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/24 9:08:28 Browse times: 331 Comment times: 0

ASP.NE技巧:GridView绑定DropdownList_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

ASP.NE技巧:GridView绑定DropdownList_[Asp.Net教程]

绑定下拉菜单,显示的时候是一个label,在点编辑的时候才显示出下拉菜单来

html代码部分:









CS代码部分

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList goodsType = (DropDownList)e.Row.FindControl("DropDownList1");
if (goodsType != null)
{
con = new SqlConnection(ConfigurationManager.ConnectionStrings["TestProviderConnectionString"].ConnectionString);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select * from goodsType",con);
da.Fill(ds,"gt");
goodsType.DataSource = ds.Tables["gt"];
goodsType.DataTextField = "goodsType";
goodsType.DataValueField = "goodsId";
goodsType.DataBind();
}
}





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.