Demo to save data in the grid; use of the CheckBox, and the use of a single button to save, retrieve, delete, and update.
HTML Code
<table id="Table1" class="tbl" width="100%">
<tr>
<td colspan="2">
<asp:label id="lblMandatory" runat="server" font-bold="False" forecolor="Red" text="All fields marked with (*) are mandatory."
cssclass="cssLableError"></asp:label>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:radiobuttonlist id="rblOperations" runat="server" repeatdirection="Horizontal">
</asp:radiobuttonlist>
</td>
</tr>
<tr id="title">
<td class="tblTDText">
DemoID :
</td>
<td>
<asp:textbox id="txtregid" runat="server" width="172px"></asp:textbox>
<script type="text/javascript">
function myfunction() {
var ctrl = '<%=txtregid.ClientID.Trim() %>';
OpenPopUp('frmchilddemoreg.aspx?ctrl=' + ctrl);
return false;
}
</script>
<asp:button id="btnterive" runat="server" width="50px" text="GO" onclick="btnterive_Click" />
<asp:button id="btnfindid" runat="server" text="FIND" style="margin-left: 32px; margin-bottom: 0px"
onclientclick="return myfunction();" />
</td>
</tr>
<tr id="titleID">
<td class="tblTDText">
Name :<span style="color: Red"> *</span>
</td>
<td>
<asp:textbox id="txtName" runat="server" onblur="return UnSelect(event,this,'AD',50);"
onfocus="return Select(event,this,'AD',50);" onkeypress="return ValdTextBox(event,this,'AD',50);"></asp:textbox>
</td>
</tr>
<tr id="titleID1">
<td class="tblTDText">
TemporaryAddress :<span style="color: Red"> *</span>
</td>
<td>
<asp:textbox id="txtAddress" runat="server" width="500px" height="50" textmode="MultiLine"
rows="10" class="TextBox" onblur="return UnSelect(event,this,'AD',200);" onfocus="return Select(event,this,'AD',200);"
onkeypress="return ValdTextBox(event,this,'AD',200);"> </asp:textbox>
</br>
<asp:checkbox id="chkaddress" runat="server" oncheckedchanged="chkaddress_CheckedChanged"
autopostback="true" />
</td>
</tr>
<tr id="titleID2">
<td class="tblTDText">
PermanentAddress :<span style="color: Red"> *</span>
</td>
<td>
<asp:textbox id="txtprmaddress" runat="server" width="500px" height="50" textmode="MultiLine"
rows="10" class="TextBox" onblur="return UnSelect(event,this,'AD',200);" onfocus="return Select(event,this,'AD',200);"
onkeypress="return ValdTextBox(event,this,'AD',200);"> </asp:textbox>
</td>
</tr>
<tr id="titleID3">
<td class="tblTDText">
Mobile No. :<span style="color: Red"> *</span>
</td>
<td>
<asp:textbox id="txtMobile" runat="server" onblur="return UnSelect(event,this,'PH',11);"
onfocus="return Select(event,this,'PH',11);" onkeypress="return ValdTextBox(event,this,'PH',11);"></asp:textbox>
</td>
</tr>
<tr id="titleID4">
<td class="tblTDText">
Email ID :<span style="color: Red"> *</span>
</td>
<td>
<asp:textbox id="txtEmail" runat="server" onblur="return UnSelect(event,this,'EM',100);"
onfocus="return Select(event,this,'EM',100);" onkeypress="return ValdTextBox(event,this,'EM',100);"></asp:textbox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:gridview width="100%" cssclass="tableReport" id="gdvDemoreg" runat="server"
enablemodelvalidation="True" autogeneratecolumns="False" allowpaging="True" allowsorting="True"
pagesize="5">
<Columns>
<asp:BoundField DataField="dem10DF1" HeaderText="ID" ReadOnly="True" />
<asp:BoundField DataField="dem10001" HeaderText="Name" SortExpression="dem9001" />
<asp:BoundField DataField="dem10002" HeaderText="TemporaryAdress" />
<asp:BoundField DataField="dem10003" HeaderText="PermanentAddress" />
<asp:BoundField DataField="dem10004" HeaderText="MobileNO." />
<asp:BoundField DataField="dem10005" HeaderText="Email" />
</Columns>
</asp:gridview>
</td>
</tr>
</table>
<script type="text/javascript">
var trTitle = null;
var trTitleID = null;
var trTitleID1 = null;
var trTitleID2 = null;
var trTitleID3 = null;
var trTitleID4 = null;
function showHide(ctrl) {
if (null == trTitle) trTitle = document.getElementById('title');
if (null == trTitleID) trTitleID = document.getElementById('titleID');
if (null == trTitleID1) trTitleID1 = document.getElementById('titleID1');
if (null == trTitleID2) trTitleID2 = document.getElementById('titleID2');
if (null == trTitleID3) trTitleID3 = document.getElementById('titleID3');
if (null == trTitleID4) trTitleID4 = document.getElementById('titleID4');
if (null != trTitle && null != trTitleID && null != trTitleID1 && null != trTitleID2 && null != trTitleID3 && null != trTitleID4)
switch (ctrl) {
case "2":
case "3":
case "4":
trTitle.style.display = '';
trTitleID.style.display = '';
trTitleID1.style.display = '';
trTitleID2.style.display = '';
trTitleID3.style.display = '';
trTitleID4.style.display = '';
break;
case "1": trTitle.style.display = 'none';
trTitleID.style.display = '';
trTitleID1.style.display = '';
trTitleID2.style.display = '';
trTitleID3.style.display = '';
trTitleID4.style.display = '';
break;
}
}
showHide('<%=rblOperations.SelectedValue %>');
$('input').attr('autocomplete', 'off')
</script>
C# Code
On Pageload Function
if (!IsPostBack)
{
//txtregid.Enabled = false;
InitPage();
}
foreach (ListItem item in rblOperations.Items)
{
item.Attributes.Add("onclick", "showHide('" + item.Value + "');");
}
On Button Event Fire
if (rblOperations.SelectedValue == "1")
{
AddRecord();
}
else if (rblOperations.SelectedValue == "2")
{
RetrieveRecord();
}
else if (rblOperations.SelectedValue == "3")
{
updateRecord();
}
else if (rblOperations.SelectedValue == "4")
{
DeleteRecord();
}
And make the specified methods as required.