I have a gridview
in which there are many checkboxes
including rows and columns. Here is a preview of the gridview below
and the aspx of the code is below
<cc1:Grid ID="GrdWorkingCompany" runat="server" OnRowDataBound="GrdWorkingCompany_RowDataBound"
EnableTypeValidation="true" CallbackMode="true" Serialize="true" ShowFooter="false"
AutoGenerateColumns="false" AllowAddingRecords="true" AllowSorting="false" Width="100%"
FolderStyle="~/Styles/Grid/style_12" PageSize="18">
<Columns>
<cc1:Column ID="Sr_No" ReadOnly="true" DataField="SrNo" HeaderText="Sr.No." Width="50px">
</cc1:Column>
<cc1:Column ID="Points" ReadOnly="true" DataField="Points" HeaderText="Points" runat="server"
Width="300px">
</cc1:Column>
<cc1:Column ID="chkPoor" ReadOnly="true" DataField="Rating1" HeaderText="Poor" Width="110px"
TemplateId="tpltPoor">
</cc1:Column>
<cc1:Column ID="chkSatisfactory" DataField="Rating2" HeaderText="Satisfactory" ReadOnly="true"
Width="110px" TemplateId="tpltSatisfactory">
</cc1:Column>
<cc1:Column ID="chkGood" ReadOnly="true" HeaderText="Good" DataField="Rating3" Width="110px"
TemplateId="tpltGood">
</cc1:Column>
<cc1:Column ID="chkExcellent" HeaderText="Excellent" DataField="Rating4" Width="110px"
ReadOnly="true" TemplateId="tpltEx1">
</cc1:Column>
</Columns>
<TemplateSettings GroupHeaderTemplateId="GroupTemplate" />
<Templates>
<cc1:GridTemplate runat="server" ID="GridTemplate2">
<Template>
<%# Container.Column.HeaderText %>
: <i>
<%# Container.Value %></i> (<%# Container.Group.PageRecordsCount %><%# Container.Group.PageRecordsCount > 1 ? "records" : "record" %>)
</Template>
</cc1:GridTemplate>
</Templates>
<Templates>
<cc1:GridTemplate ID="tpltPoor">
<Template>
<input type="checkbox" id="chkA1<%# (Container.RecordIndex)%>" name="chkAC1" style="width: 17px;
height: 17px;" value="<%# (Container.RecordIndex)%>" onclick="AppoveCheckA(this)" /></Template>
</cc1:GridTemplate>
<cc1:GridTemplate ID="tpltSatisfactory">
<Template>
<input type="checkbox" id="chkA2<%# (Container.RecordIndex)%>" name="chkAC2" style="width: 17px;
height: 17px;" value="<%# (Container.RecordIndex)%>" onclick="AppoveCheckA(this)" /></Template>
</cc1:GridTemplate>
<cc1:GridTemplate ID="tpltGood">
<Template>
<input type="checkbox" id="chkA3<%# (Container.RecordIndex)%>" name="chkAC3" style="width: 17px;
height: 17px;" value="<%# (Container.RecordIndex)%>" onclick="AppoveCheckA(this)" /></Template>
</cc1:GridTemplate>
<cc1:GridTemplate ID="tpltEx1">
<Template>
<input type="checkbox" id="chkA4<%# (Container.RecordIndex)%>" name="chkAC4" style="width: 17px;
height: 17px;" value="<%# (Container.RecordIndex)%>" onclick="AppoveCheckA(this)" /></Template>
</cc1:GridTemplate>
</Templates>
</cc1:Grid>
So, Now what I want is
I want to save the checked checkbox value into the database table on button click
What I tried is below:-
/*1st Grid GrdWorkingCompany saving code*/
string[] arrS = hidRateA.Value.Split(new char[] { ',' });
if (arrS.Length != 18)
{
arrS = "0,0,0,0".Split(new char[] { ',' });
}
for (int intCount = 0; intCount < arrS.Length; intCount++)
{
xw.WriteStartElement("p_emp_Company_Rating");
xw.WriteElementString("CREATED_BY", Hid_userid.Value);
xw.WriteElementString("CREATION_DATE", System.DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));
xw.WriteElementString("LAST_UPDATE_DATE", System.DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));
xw.WriteElementString("LAST_UPDATED_BY", Hid_userid.Value);
xw.WriteElementString("Sr_no", (intCount + 1).ToString());
xw.WriteElementString("Points", "");
for (int i = 1; i < 5; i++)
{
if (arrS[intCount] == i.ToString() && arrS[intCount] != "0")
{
xw.WriteElementString("Rating" + i.ToString(), "Y");
}
else
{
xw.WriteElementString("Rating" + i.ToString(), "N");
}
}
xw.WriteElementString("DELETE_FLAG", "N");
xw.WriteEndElement();
}
But it is not getting saved.
If there is any other way round to achieve this kindly help me out.
Aucun commentaire:
Enregistrer un commentaire