如何根据其他网格获取网格控件 [英] how to get the grid controls based on the other grid

查看:67
本文介绍了如何根据其他网格获取网格控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







i有两个网格grid1和grid2。



grid1的最后一列有下拉列表。




$ 2 $ b在grid2中我们点击添加按钮,我们获得新行。按钮点击新行将添加到grid2。





现在我的要求是每当我在grid2中有新行时,应自动添加一个复选框to griddown




i have two grid grid1 and grid2.

grid1 has last column has dropdown.


in grid2 we have add button on clicking which we get new rows.on button click new row will be added to grid2.


now my requirement is whenever i had new row in grid2 automatically a check box should be added to dropdown in grid1

推荐答案

如果你想在 DropDownList中添加 CheckBox ,然后您必须以其他方式执行此操作,因为 DropDownList 不支持此类默认行为。



所以,你应该去 DropDownCheckList ASP.NET服务器控件 [ ^ ] 。



您可以将其添加到 GridView 并尝试。



一切顺利。 :)
If you want to add CheckBox inside DropDownList, then you have to do it in some other way because there is no such default behaviour supported by DropDownList.

So, you should go for DropDownCheckList ASP.NET Server Control[^].

You can add this to your GridView and try.

All the best. :)


尝试这样的事情..

Try something like this..
protected void btnGrid2Insert_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow gvRow in gvGrid1.Rows)
        {
            DropDownList ddl = (gvRow.Cells[5].FindControl("ddlName") as DropDownList);
            DataTable dt = getYourSource();
            ddl.DataSource = dt;
            ddl.DataTextField = "";
            ddl.DataValueField = "";
            ddl.DataBind();
        }
    }


这篇关于如何根据其他网格获取网格控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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