<asp:GridView ID="gvData" runat="server" Width="100%" AutoGenerateColumns="false" EmptyDataText="No record found" AllowSorting="false" AlternatingRowStyle-CssClass="alt" CssClass="myGrid" OnRowDataBound="gvData_RowDataBound" OnRowCommand="gvData_RowCommand"> <Columns> <asp:BoundField HeaderText="Id" ItemStyle-HorizontalAlign="Left" DataField="RewardId" Visible="false" /> <asp:BoundField HeaderText="Name" ItemStyle-HorizontalAlign="Left" DataField="AccountName" /> <asp:BoundField HeaderText="Email" ItemStyle-HorizontalAlign="Left" DataField="Email" /> <asp:BoundField HeaderText="Status" ItemStyle-HorizontalAlign="Left" DataField="StatusName" /> <asp:BoundField HeaderText="Cash Back" ItemStyle-HorizontalAlign="Right" DataField="CashBack" /> <asp:BoundField HeaderText="ATM Refund" ItemStyle-HorizontalAlign="Left" DataField="ATMRefund" /> <asp:BoundField HeaderText="Send On" ItemStyle-HorizontalAlign="Left" DataField="SendOn" /> <asp:TemplateField> <ItemTemplate> <asp:LinkButton runat="server" ID="lnkView" CommandName="View" CommandArgument='<%# Eval("RewardId") %>' Text="View"></asp:LinkButton> </ItemTemplate> </asp:TemplateField> <asp:BoundField HeaderText="Status" ItemStyle-HorizontalAlign="Left" DataField="Status" Visible="false" /> </Columns> </asp:GridView>
protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int rewardId = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "RewardId").ToString()); if (rewardId < 0) { e.Row.Cells.Clear(); TableCell cell = new TableCell(); cell.Text = "Account Name : " + DataBinder.Eval(e.Row.DataItem, "AccountName").ToString(); cell.ColumnSpan = 7; cell.CssClass = "GroupHeaderStyle"; e.Row.Cells.Add(cell); } } } protected void gvData_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandArgument != null) { try { var strDataId = e.CommandArgument; if (strDataId != null && e.CommandName == "View") { int intID = Convert.ToInt32(strDataId); if (intID > 0) { FillData(intID); } } } catch (Exception ex) { } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)