热门以获取下拉列表中的选定数据以进行编辑 [英] Hot To Get Selected Data in Dropdownlist to Edit

查看:46
本文介绍了热门以获取下拉列表中的选定数据以进行编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi iam net to asp.net,我希望将所选数据保存到dropdownlist进行编辑,我将数据检索到所有控件,但是当我使用时无法进入下拉列表

hi iam net to asp.net and i want to get selected data was saved to dropdownlist to edit it, i retrieve data to all controls ok but can''t get in dropdownlist when i use

DropDownList.SelectedItem.Text= dr["FiledName"].ToString();





它显示在下拉列表副本中,当我使用时



it show in dropdownlist duplicate and when i use

DropDownList.Items.Add(dr.GetString(0));



它不会在dropdownlist中显示任何但重复的数据


it doesn''t show any thing but duplicate data in dropdownlist

推荐答案

试试这个。可能有帮助。找到列表中项目的好方法,如果找到,则将其设置为选中状态。



Try this. May help. good way to find the item in the list and if found set it selected.

if(DropDownList1.Items.FindByText(dr["FiledName"].ToString())!=null)
{
                DropDownList1.Items.FindByText(dr["FiledName"].ToString()).Selected = true;

}







~Prashant




~Prashant


试试这个



try this

DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByText(dr["FiledName"].ToString()));


这篇关于热门以获取下拉列表中的选定数据以进行编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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