设置的SelectedValue在GridView的一个DropDownList [英] Setting selectedvalue for a dropdownlist in GridView
本文介绍了设置的SelectedValue在GridView的一个DropDownList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的GridView一个DropDownList,我的数据源绑定到GridView。
I have a dropdownlist in my Gridview and I am binding a datasource to the gridview.
尽管所有的记录都显示正常未选择下拉值。
Though all the records are displaying properly the dropdown value is not selected.
我如何设置类似
<%#绑定(国家)%方式>
为在GridView在ASP.net一个DropDownList
<%# Bind("Country") %>
for a dropdownlist in the Gridview in ASP.net.
感谢
推荐答案
您可以挂接到RowDataBound事件的网格视图,找到控制和设置的值。
You can hook into the RowDataBound event for the grid view, find the control and set the value.
protected void gridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
var dropdownList = e.Row.FindControl("YOUR_DROP_DOWN") as DropDownList;
dropdownList .SelectedIndex = SET_VALUE_HERE;
}
这篇关于设置的SelectedValue在GridView的一个DropDownList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文