在gridview中绑定的DDL行 [英] DDL row bound in gridview

查看:73
本文介绍了在gridview中绑定的DDL行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gridview coloumn中有一个DDL。

和一个名为product_size的数据库表中插入了大小值(5pc,10pc,15pc)

在gridview中我想从gridview中的数据库中绑定这个ddl ...并填充它。

Plzz帮助我,我尝试了很多但是成功... !!





推荐答案

请参考此代码它将对您有所帮助..

Refer this code it will help you..
protected void RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow && gvProduct.EditIndex == e.Row.RowIndex)
    {
        DropDownList product_size= (DropDownList)e.Row.FindControl("ddlproduct_size");
        string query = "select distinct product_size from product";
        SqlCommand cmd = new SqlCommand(query);
        ddlCities.DataSource = GetData(cmd);
        ddlCities.DataTextField = "product_size";
        ddlCities.DataValueField = "product_size";
        ddlCities.DataBind();
        ddlCities.Items.FindByValue((e.Row.FindControl("lblproduct_size") as Label).Text).Selected = true;
    }
}






请看一下这个首先,





http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound(v = VS .110).aspx [ ^ ]



http://www.dotnetgallery.com/kb/resource17-RowDatabound-event-tips-and-tricks-in- Gridview-control.aspx [ ^ ]



这将是最终的......



http://www.aspdotnet-suresh.com/2012/05/bind-data- to-dropdownlist-in-gridview.html [ ^ ]
Hi ,

Please look into this first,


http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound(v=vs.110).aspx[^]

http://www.dotnetgallery.com/kb/resource17-RowDatabound-event-tips-and-tricks-in-Gridview-control.aspx[^]

This will be final...

http://www.aspdotnet-suresh.com/2012/05/bind-data-to-dropdownlist-in-gridview.html[^]


这篇关于在gridview中绑定的DDL行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆