I am using this gridview, I have one header checkbox and one column containing textbox. I want that when i check the header checkbox the value of every textbox changes from 0 to 1.
<asp:GridView ID="grdData" runat="server" style="Text-align:center;">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</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" Text="0"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
You can do this by using Jquery.
Not tested with the actual data, but hope this should work for you.
$(function () {
$('#CheckBox2').change(function () {
$("#TextBox1").val(($(this).is(':checked')) ? "1" : "0");
});
});
Also you must need to add jquery plugin right before the javascript code which I gaved u. Below is one of the plugin which you can use
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
Do let us know if it works or not
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.