asp.net - Get child page data from master page selectedItems -
i have location dropdownlist in master page. have set control in child page takes properties master page. running query
select * table city '"+city.text+"' here city.text gets value master page selected cities. problem it's not showing records per city.text has values in it. shows random records.
my code
master page
<asp:dropdownlist id="locationselector" runat="server" autopostback="true"> <asp:listitem selected>pune</asp:listitem> <asp:listitem>delhi</asp:listitem> <asp:listitem>chennai</asp:listitem> <asp:listitem>bangalore</asp:listitem> <asp:listitem>mumbai</asp:listitem> </asp:dropdownlist> child page vb code
dim location dropdownlist = page.master.findcontrol("locationselector") city.text = location.selecteditem.tostring if not ispostback try query = "select * hospitals city '" + city.text + "'" dim cmd new mysqlcommand(query, con) cmd.commandtimeout = 120 dim da new mysqldataadapter(cmd) dim table new datatable da.fill(table) viewstate("data") = table hospitals.datasource = table hospitals.databind() catch ex exception response.write(ex) end try end if update
protected sub hospitals_prerender(byval sender object, byval e system.eventargs) handles me.prerender dim location dropdownlist = page.master.findcontrol("locationselector") city.text = location.selecteditem.tostring end sub sometimes throws timeout error. of time gets results not per selected items. other solution this?
i suggest use prerender event within page. in prerender event try access master page control , value.
Comments
Post a Comment