Hello there,
Hopefully I didnt post this request already, I didnt find anything about it:
We're setting the datasource of the webdatagrid quite simple:
roleTypes = roleTypes.Where(r => !specialRoles.Contains(r.CDE)).ToList(); ddlControl.DataSource = roleTypes; ddlControl.TextField = "DESCR"; ddlControl.ValueField = "CDE"; ddlControl.DataBind();
Nothing special hier, some business logic, then we create a list out of it, set the text- and value-field and bind it.
Works perfect so far, after the binding the first item is selected, which is ok. But when the user doesnt change the selection, the selectedvalue keeps empty and SelectedIem is null.
Only after a manual change of the selection, these 2 properties are filled.
Is that a bug? Since the text is shown, I'd guess this two properties should be filled as well.
Thanks for your response
Matthias
Hello Matthias,
Thank you for posting to Infragistics forums!
Selected item should be set explicity like below:
if(!ispostback)
{
this.webdropdownprovideer.selecteditemindex=1;
}
Let me know if you have any questions.
Helllo Prabha,
should that work with javascript as well?
I cant do that in code behind.
Hello Prabha,
thanks for your response.
I'll try that out.
You can set the selecteitem for the webdropdown on the client side like below in the intialize event :
var dd = $find('<%= WebDropDown1.ClientID %>');
var items = dd.get_items();
items.getItem(1).select(); // marks the item with selected flag (i.e. on next postback it will be selected on the server as well), as well as changes the selected style var text = items.getItem(1).get_text();
dd.set_currentValue(text,true); // sets the text for "currentValue" in the object model, as well as update the actual input text }