asp.net - What will be the Sql Query to compare the value of two hyperlinks bounded within the item template of Reapeter? -
i have having repeater(repeater1) , hyper link , repeater(repeater2) in item template of repeater(repeater1).then repeater2 contain hyperlink. hyperlink of repearet1 category , hyperlink of repeater2 subcategory.
as shown code
<ul class="categories" id="categoryheader"> <li id="categoryitem"> <h4>categories</h4> <ul class="categories" id="categorylist"> <asp:repeater id="repcategories" runat="server" onitemdatabound="repcategories_itemdatabound"> <headertemplate> <ul> </headertemplate> <itemtemplate> <li> <asp:hyperlink id="hypercategories" runat="server"><%#eval("categoryname")%></asp:hyperlink> <ul class="subcategories" id="subcategorylist"> <asp:repeater id="repsubcategory" runat="server"> <headertemplate> <ul> </headertemplate> <itemtemplate> <li> <asp:hyperlink id="hypersubcategories" runat="server"><%#eval("subcategoryname")%></asp:hyperlink> </li> </itemtemplate> <footertemplate></ul></footertemplate> </asp:repeater> </ul> </li> </itemtemplate> <footertemplate></ul></footertemplate> </asp:repeater> </ul> </li>
and category , subcategory tables follows ->
productcategory column name data type constraint categoryid varchar(20) primary key categoryname varchar(100) unique key description varchar(1000) productsubcategory column name data type constraint subcategoryid int auto increment , primary key subcategoryname varchar(100) description varchar(1000) categoryid varchar(20) foreign key product category
i have used query bind repeater database
{ protected void page_load(object sender, eventargs e) { if (!ispostback) { dataset ds = new viewaction().getallproductcategorydata(); repcategories.datasource = ds; repcategories.databind(); dataset ds1 = new viewaction().getallcompanyinfodata(); repcompany.datasource = ds1; repcompany.databind(); //dataset ds2 = new viewaction().getallproductsubcategorydata(); //repsubcategory.datasource = ds2; //repsubcategory.databind(); } } protected void itembound(object sender, repeateritemeventargs args) { if (args.item.itemtype == listitemtype.item) { repeater childrepeater = (repeater)args.item.findcontrol("repsubcategory"); var item = args.item repeateritem; sqlcommand cmd = dataconnection.getconnection().createcommand(); cmd.commandtext = "select productsubcategory.categoryid,productsubcategory.subcategoryname,productcategory.categoryid productsubcategory right join productcategory on productsubcategory.categoryid=@hypercategory"; sqldataadapter da = new sqldataadapter(cmd); dataset ds = new dataset(); da.fill(ds); cmd.dispose(); childrepeater.datasource = ds; //childrepeater.datasourceid = "categoryid"; childrepeater.databind(); dataconnection.closeconnection(); } } protected void repcategories_itemdatabound(object sender, repeateritemeventargs e) { repeateritem item = e.item; if ((item.itemtype == listitemtype.item) || (item.itemtype == listitemtype.alternatingitem)) { repeater repsubcategory = (repeater)item.findcontrol("repsubcategory"); string hypercategories = hypercategory.text; datarowview drv = (datarowview)item.dataitem; sqlcommand cmd = dataconnection.getconnection().createcommand(); cmd.commandtext = "select productsubcategory.categoryid,productsubcategory.subcategoryname,productcategory.categoryid productsubcategory right join productcategory on productsubcategory.categoryid=productcategory.categoryid"; sqldataadapter da = new sqldataadapter(cmd); dataset ds = new dataset(); da.fill(ds); cmd.dispose(); repsubcategory.datasource = ds; //childrepeater.datasourceid = "categoryid"; repsubcategory.databind(); dataconnection.closeconnection(); } } }
acc me query wrong
cmd.commandtext = "select productsubcategory.categoryid,productsubcategory.subcategoryname,productcategory.categoryid productsubcategory right join productcategory on productsubcategory.categoryid=@hypercategory";
it fetch subcategories each category.
please tell me right query can manipulate query based on value of 2 hyperlinks please.
Comments
Post a Comment