Hiding dropdownlist in templatefield in gridview asp.net C# after insert into the database -
i have problem, after value dropdown list picked up, inserted db hide dropdown list , show grade of product user rated, on 2 following pictures:
this first picture showing how user needs insert grade db of product:
the result after should following:
the dropdownlist should invisible user rated product. have tried using rowdatabound event , following code:
if (e.row.rowtype == datacontrolrowtype.datarow) { hsp_narudzbe_detalji_result k = (hsp_narudzbe_detalji_result)e.row.dataitem; if (k.ocjena!=null) { e.row.cells[4].text = k.ocjena; } }
but doesn't works, shows grade once, , when press button grading product, dropdown list back... :/
can me out this?
edit (aspx code of page):
<asp:gridview id="griddetaljinarudzbe" autogeneratecolumns="false" allowpaging="true" pagesize="10" runat="server" onrowcommand="griddetaljinarudzbe_rowcommand" onpageindexchanging="griddetaljinarudzbe_pageindexchanging" onrowdatabound="griddetaljinarudzbe_rowdatabound"> <columns> <asp:boundfield datafield="naziv" headertext="naziv" /> <asp:boundfield datafield="sifra" headertext="Šifra" /> <asp:boundfield datafield="cijena" headertext="cijena" /> <asp:boundfield datafield="kolicina" headertext="količina" /> <asp:templatefield headertext="ocjena"> <itemtemplate> <asp:dropdownlist id="dropdownlist1" runat="server"></asp:dropdownlist> </itemtemplate> </asp:templatefield> <asp:templatefield> <itemtemplate> <asp:linkbutton id="btnocijeni" title="ocijeni proizvod" commandname="ocijenicommand" commandargument='<%#eval("proizvodid") + ";" +((gridviewrow) container).rowindex%>' runat="server"><img src="../images/ocijeni.png" /></asp:linkbutton> </itemtemplate> </asp:templatefield> </columns> </asp:gridview>
the grades loaded this:
if (e.row.rowtype == datacontrolrowtype.datarow) { dropdownlist drop = e.row.findcontrol("dropdownlist1") dropdownlist; drop.items.add(new listitem("")); drop.items.add(new listitem("1")); drop.items.add(new listitem("2")); drop.items.add(new listitem("3")); drop.items.add(new listitem("4")); drop.items.add(new listitem("5")); }
try this,
protected void gridview1_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { dropdownlist ddl = e.row.cells[4].findcontrol("dropdownlist2") dropdownlist; if (ddl != null) { // if (your_condition == true) //{ ddl .visible = false; //} } } }
Comments
Post a Comment