Hi nedash,
I have created sample code which full-fill your requirement.So please refer the below code and modify as per your requirement.
HTML
<div>
<asp:ScriptManager runat="server" />
<asp:GridView ID="GrdMessage" runat="server" AutoGenerateColumns="false" Font-Size="14px"
PageSize="5" GridLines="Both" Width="338px" BorderColor="#808080" BorderStyle="Solid"
BorderWidth="1px" RowStyle-BorderColor="#808080" RowStyle-BorderStyle="Solid"
RowStyle-BorderWidth="1px" AlternatingRowStyle-BackColor="#C0C0C0" PagerStyle-HorizontalAlign="Center"
PagerStyle-VerticalAlign="Middle" ShowHeader="False" Font-Names="behtop_Yekan"
BackColor="#Fcfcfc" CssClass="gridGalary">
<Columns>
<asp:TemplateField ItemStyle-Width="0px">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Eval("ID")%>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="54px" ItemStyle-VerticalAlign="Middle" ItemStyle-Height="38px">
<ItemTemplate>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<label id="Label1" runat="server" class="chlinkDoc1">
<input type="checkbox" id="ChBpriceL" runat="server" class="chlinkDoc1" />
</label>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="282px" ItemStyle-VerticalAlign="Middle">
<ItemTemplate>
<asp:Label ID="Lblname" runat="server" Text='<%#Eval("GroupName").ToString()%>' CssClass="lblQGK"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('[Id*=ChBpriceL]').click(function () {
var obj = {};
obj.Id = '';
obj.group='';
obj.status = '';
if ($('[Id*=ChBpriceL]').is(':checked')) {
obj.Id = 1;
obj.group=$(this).closest('tr').find("span[id*=Lblname]").text();
obj.status = "Check";
}
else {
obj.Id = 1;
obj.status = "Uncheck";
}
$.ajax({
type: "POST",
url: "Default.aspx/SendParameters",
data: JSON.stringify(obj),
contentType: "application/json; charset=utf-8",
dataType: "json",
});
});
});
</script>
</div>
</div>
C#
[System.Web.Services.WebMethod]
public static void SendParameters(string Id, string status, string group)
{
string constring = ConfigurationManager.ConnectionStrings["constr"].ToString();
SqlConnection con = new SqlConnection(constring);
if (status.ToUpper() == "CHECK")
{
SqlCommand cmd = new SqlCommand("Update TableName SET " + group + "='1' WHERE Id='" + Id + "'", con);
cmd.Parameters.AddWithValue("@Id", Id);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
else
{
SqlCommand cmd = new SqlCommand("Update TableName SET " + group + "='0' WHERE Id='" + Id + "'", con);
cmd.Parameters.AddWithValue("@Id", Id);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
Vb.Net
<System.Web.Services.WebMethod> _
Public Shared Sub SendParameters(Id As String, status As String, group As String)
Dim constring As String = ConfigurationManager.ConnectionStrings("constr").ToString()
Dim con As New SqlConnection(constring)
If status.ToUpper() = "CHECK" Then
Dim cmd As New SqlCommand((Convert.ToString((Convert.ToString("Update TableName SET ") & group) + "='1' WHERE Id='") & Id) + "'", con)
cmd.Parameters.AddWithValue("@Id", Id)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Else
Dim cmd As New SqlCommand((Convert.ToString((Convert.ToString("Update TableName SET ") & group) + "='0' WHERE Id='") & Id) + "'", con)
cmd.Parameters.AddWithValue("@Id", Id)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End If
End Sub
Screenshot