gridview中的多个下拉列表,可在asp.net C#中编辑 [英] multiple dropdownlists in gridview with editable in asp.net C#

查看:93
本文介绍了gridview中的多个下拉列表,可在asp.net C#中编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个带有两个下拉菜单国家和州的网格视图,当我点击编辑按钮时,下拉菜单选择值应该在编辑模式下显示,请提供一些样本或代码..





在此先感谢..

Raghu。

Hi,
I have a gridview with two dropdowns country and state when i click on edit button the dropdowns selected values should be displayed on edit mode please give some samples or code..


Thanks in Advance..
Raghu.

推荐答案

转到GridView的RowDataBound事件,找到EditItemTemplate中的DropDownList并绑定数据并在那里设置所选值。

试试这个:

Go to your RowDataBound Event of GridView, Find the DropDownList which is in EditItemTemplate and bind the data and set the selected value there.
Try this:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        DropDownList ddlCountry = e.Row.FindControl("ddlCountry") as DropDownList;

        if (ddlCountry != null){
            // Write your code to bind dropdownlist and set it's selected value here.
        }
    }
}





请参阅此示例在GridView RowEditing命令中绑定DropDownList [ ^ ]。





--Amit


OR
See and example here for Binding DropDownList in GridView RowEditing Command[^].


--Amit






i认为它可能对你有帮助$



ASP.NET 2.0中的可编辑GridView [ ^ ]


这篇关于gridview中的多个下拉列表,可在asp.net C#中编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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