我有一个gridview
,并且在单击asp:Button
时在表格中插入了所有gridview行,现在我想显示将Gridview行明智地插入到数据库中,例如
如果插入了一行,则应用插入的行的某些CSS(在gridview中),例如该行的(更改背景色),然后下一步并显示。.但是我不知道该怎么做?
gridview
<asp:GridView ID="GridView2" CssClass="table table-striped table-hover" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="checkbox1" runat="server" Checked="true" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SNo">
<ItemTemplate>
<%#Container.DataItemIndex+1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="GFname" HeaderText="Name" />
<asp:BoundField DataField="Address1" HeaderText="Address 1" />
<asp:BoundField DataField="Address2" HeaderText="Address 2" />
<asp:BoundField DataField="MobileNo" HeaderText="Mobile No" />
<asp:BoundField DataField="Location" HeaderText="Location" />
<asp:BoundField DataField="City" HeaderText="City" />
</Columns>
</asp:GridView>
asp:button
<asp:Button runat="server" ID="btnsndwish" Style="margin-top: 15px;" Text="Send SMS" CssClass="btn btn-primary filter-dates" OnClick="btnsndwish_Click"></asp:Button>
cs
foreach (GridViewRow g1 in GridView2.Rows)
{
CheckBox chk = (CheckBox)g1.FindControl("checkbox1");
if (chk != null && chk.Checked)
{
string Query = "insert into SMSTable(MobileNo,MessageToSent,MessageDate,UserId,SentDate,Flag,GuestName) Output Inserted.ID as ID,Inserted.Trycount as Trycount values ('" + g1.Cells[5].Text + "','" + txtmsg.Value + "','" + CurrentDate.ToString("dd-MMM-yyyy HH:mm:ss") + "','','" + CurrentDate.ToString("dd-MMM-yyyy HH:mm:ss") + "',0,'" + g1.Cells[2].Text + "')";
ds = obj.GetDataSet(Query);
if (ds.Tables[0].Rows.Count > 0)
{
}
ScriptManager.RegisterStartupScript(this, this.GetType(), "Success", "alert('MSG Sent');", true);
return;
}
}