Last post Mar 14, 2016 07:59 AM by oned_gk
Mar 13, 2016 06:12 PM|Taufikandrian|LINK
Mar 14, 2016 06:12 AM|Klein Zhang|LINK
When i page load, i want my dropdown list selected value get the data from database result,,,anyone can help me please!!!! :(
You need to fill the DropDownList possible options before you set the selected value which you are trying to do inline with the Eval. You could switch it to use the ondatabinding of the DropDownList and do what you need there. If you'd like to bind the
dropdownlist in the itemdatabound, you could use the following code.
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
// Get the view class for the current repeater record
var dataSource = e.Item.DataItem;
DropDownList dropDownList = (DropDownList)e.Item.FindControl("ddlOptions");
if (dropDownList != null)
dropDownList.DataSource = dataSource; //Or any other datasource
And you could refer to the following links to get more information.
Mar 14, 2016 07:59 AM|oned_gk|LINK
use hiddenfield bind value property to database field then get it using findcontrol method
var value = DataBinder.Eval(e.Item.DataItem, "fieldname");