Last post Feb 26, 2010 09:34 PM by RonJac
Feb 26, 2010 01:58 PM|RonJac|LINK
Im using a web form that contains a button(having id=btnSubmit) dropdownlist(having id='ddlDynamic') and a panel which has a dynamicpopulateextender that makes use of the fllg webservice method
public static string GetDynamicContent3(string contextKey)
DropDownList lsDynamic = new DropDownList();
lsDynamic.ID = "lsDynamic";
lsDynamic.Items.Selected = true;
/*These values are just sample values which will actually be coming from a database
Even the item is selected based on another database value*/
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
Now at page load this panel will already be containing an empty listbox with id 'lsDynamic'
As you can see I am creating a new listbox with a selected item in the panel to replace the old empty one.(I hope my terminology is correct)
This web service method kicks into action when i change the index of ddlDynamic
The listbox and the selecteditem also gets rendered fine inside the panel but when i click btnSubmit, I am unable to retrieve the selected index of the listbox
It always returns Null. Is there something else i need to do in order to properly register the new control I have added so that server side events can handle it
Do help me out in this regard.
Let me know if you guys need any more info which would help you solve my problem
Kindly forgive me if I ve forgotten to do something very obvious because as i said 'Im new to Ajax'
Feb 26, 2010 03:27 PM|Prof_Teancum|LINK
It is probably easier to just put an update panel around the dropdownlist and do the database stuff on partial postback. I think it is returning null because it is being changed client-side.
Feb 26, 2010 09:34 PM|RonJac|LINK
Ok fine. I ll drill down my question like this.
Using dynamicpopulateextender on asp textboxes to make them populate on the OnChange event of a combobox works fine and I am able to retrieve the values on btnSubmit_Click.
Similarly is there any way to select the correct listbox value (the listbox already has values from which i only need the dynamicpopulateextender to SELECT the correct value based on database calculations). I hope i dint confuse you now.
Yea the update panel thing will work Im sure of it. But then i gotta encompass the other forms too in an update panel and I have to remove the dynamic populate extender and the webservice methods from all the controls in subsequent form.
Sorry If im askin a bit too much but is there any way to dynamically select a listboxitem based on a combobox value(via database). Any extender would be helpful.
Even a radiobuttonlist instead of a listbox would be fine. I just need the for user to be able to see the correct option that is selected and he should be able to modify the value by changing the selected item of the listbox (or radiobuttonlist or whatever
control works out) and the modified value ought to get updated in the database when i click the submit buton.
Sorry if my previous question was not so clear.