|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
set dropdownlist value in datalistdoes anyone know how to set dropdownlist value in datalist? here's my code.. in editprofile.aspx: <asp:datalist id=mydl runat=server> <asp:dropdownlist id=title runat=server> <asp:listitem value="ms.">ms.</asp:listitem> <asp:listitem value="mr.">mr.</asp:listitem> <asp:listitem value="mrs.">mrs.</asp:listitem> <asp:listitem value="miss">miss</asp:listitem> </asp:dropdownlist> </asp:datalist> Then in my editprofile.aspx.vb Page_load sub Dim i As Integer For i = 0 To title.Items.Count - 1 If title.Items(i).Value = "mr." Then title.SelectedIndex = i Exit For End If Next Executing this I got error: Object reference not set to an instance of an object. Can anyone help ple,ase.... >_< Is this what you're looking for?
DropDownList.ClearSelection(); DropDownList.Items.FindByValue("Foo").Selected = true; -Brock DevelopMentor http://staff.develop.com/ballen Show quoteHide quote > hi! > does anyone know how to set dropdownlist value in datalist? > here's my code.. > in editprofile.aspx: > <asp:datalist id=mydl runat=server> > <asp:dropdownlist id=title runat=server> > <asp:listitem value="ms.">ms.</asp:listitem> > <asp:listitem value="mr.">mr.</asp:listitem> > <asp:listitem value="mrs.">mrs.</asp:listitem> > <asp:listitem value="miss">miss</asp:listitem> > </asp:dropdownlist> > </asp:datalist> > Then in my editprofile.aspx.vb Page_load sub > > Dim i As Integer > For i = 0 To title.Items.Count - 1 > If title.Items(i).Value = "mr." Then > title.SelectedIndex = i > Exit For > End If > Next > Executing this I got error: > Object reference not set to an instance of an object. > Can anyone help ple,ase.... >_< >
Other interesting topics
Get Value of a control from my Own Control
Parser Error ASP datagrid not passing text to Excel Call Page from Control asp:button Text= Binding to listbox / using data access object Urgent User COntrol Looking for sorted list webcontrol IE6 Style Buttons the process cannot access the file because it is being used by another process |
|||||||||||||||||||||||