c# - Value insertion in database from GridView -
i have 1 column of textbox
, 1 column of checkbox
in itemtemplate
in gridview , number of rows generating dynamically.
when click on checkbox
value of textbox
changing when inserting values database, default value have given in textbox
saving that.
<asp:gridview id="grddata" runat="server" style="text-align: center;"> <columns> <asp:templatefield> <itemtemplate> <asp:checkbox id="checkbox1" runat="server" onclick="changetextvalue(this)" /> </itemtemplate> <headertemplate> <!-- <asp:checkbox id="checkbox2" runat="server"onclick="checkallemp(this)" />--> </headertemplate> </asp:templatefield> <asp:templatefield> <headertemplate> <asp:label id="status_header" runat="server" text="status" /> </headertemplate> <itemtemplate> <asp:textbox id="textbox1" runat="server" enabled="false" text="1" clientidmode="static"></asp:textbox> </itemtemplate> </asp:templatefield> </columns> </asp:gridview>
i found solution, remove enabled="false"
property textbox1
, check.
<asp:textbox id="textbox1" runat="server" enabled="false" text=1 clientidmode="static"></asp:textbox>
if want disabled textbox end user, suggest use label control instead of textbox.
here jquery function label control.
<script> function changetextvalue(chk) { var currenttextid = $(chk).parents('tr').find('span[id$="label1"]'); alert(chk.checked + ": " + currenttextid.text()); if (chk.checked == true) currenttextid.text("present"); else currenttextid.text("absent"); } </script>
label control should below:
<asp:label id="label1" runat="server" text="absent" enableviewstate="false" clientidmode="static"></asp:label>
please let me know if have questions.
Comments
Post a Comment