开发者

Dropdownlist shows duplicate values while editing a row in the gridview

Well the dropdownlist has an existing items. I just want the selected gridview record to be displayed in the dropdownlist. The dropdownlist has several DataTextField in string and consist of DataValueField in numeric. The gridview passes a string text to the box which has an equal or same item inside the dropdownlist. Whenever i passed a record from a gridview to be viewed in the dropdownlist it just duplicates the same item. Q: How can i simply pass a text inside the dropdown and just simply display it without adding on the list.

sample item on the dropdown: --Select-- Account Savings

after selecting on the gridview and disp开发者_运维技巧lay inside the dropdown: Account Account Savings

(you see the '--Select--' was erase and replace with the selected record)


If I'm understanding you correctly, you have a table where one column is a lookup from a selection list.

When you're editing the list, you want to select the item in the drop down that corresponds to the displayed item in the normal view mode.

If that's the case, you want to get the select ID or the selected Text for the dropdown.

If you're using the numeric ID then you want:

Dropdownlist.Items.FindByValue(value).Selected = true;

If you're using the text then you want:

DropDownList.SelectedValue = DropDownList.Items.FindByText("Text").Value


From your text it seems you are adding items to a dropdownlist while you just want to change selection based on the Text property. To achieve that you can just do:

DropDownListId.Text = "text value";

That should work, but I didn't test it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜