c# - passing data to another page from nlevel menu -
i have multi level menu asp.net c# gets items database table. table has items: menuid, menuname, description, parentid. code below.
<asp:menu id="menubar" runat="server" orientation="horizontal" width="80%" onmenuitemclick="menubar_menuitemclick" height="28px"> </asp:menu>
and code behind is:
public void connect() { con = new sqlconnection(system.configuration.configurationmanager.connectionstrings["cnstring"].connectionstring); } private void getmenu() { connect(); con.open(); dataset ds = new dataset(); datatable dt = new datatable(); string sql = "select * tbl_webmenu"; sqldataadapter da = new sqldataadapter(sql, con); da.fill(ds); dt = ds.tables[0]; datarow[] drowpar = dt.select("parentid=" + 0); foreach (datarow dr in drowpar) { menubar.items.add(new menuitem(dr["menuname"].tostring(), dr["menuid"].tostring())); } foreach (datarow dr in dt.select("parentid >" + 0)) { menuitem mnu = new menuitem(dr["menuname"].tostring(), dr["menuid"].tostring()); mnu.enabled = true; } con.close(); }
i have page it's name description.aspx. when clicking on 1 of menu items, want redirect description page , show description of selected menu item. think should use querystring, on menuitem click: responce.redirect(description.aspx?id=something) problem don't know how id of selected item of menu , pass description page. please me. thank you
you can add parameters value when adding items menu , retrieve these in on click event handler.
protected void menubar_menuitemclick(object sender, menueventargs e) { response.redirect("somepage.aspx?id=" + e.commandargument); }
Comments
Post a Comment