Creating Customized Grid View
<asp:GridView ID=”GV” OnRowDataBound=”Gv_RowDataBound” Width=”96%” runat=”server”
AutoGenerateColumns=”False” ShowFooter=”True” BorderWidth=”1px” OnRowEditing=”gv_RowEditing”
OnRowDataBound=”gv_RowDataBound” OnRowUpdating=”gv_RowUpdating” OnRowDeleting=”gv_RowDeleting”
OnRowCancelingEdit=”gv_RowCancelingEdit” OnRowCommand=”OnRowCommandBTC” TabIndex=”3″
RowStyle-HorizontalAlign=”Center”>
</asp:GridView>
DataTable BTC = ViewBTCData().Tables[0]; // data from some data table source
gvBenefitType.DataSource = null;
gvBenefitType.DataSource = BTC;
gvBenefitType.DataBind();
Public void Gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.EmptyDataRow)
{
DataRowView datarow = (DataRowView)e.Row.DataItem;
GridViewRow currentRow = (GridViewRow)e.Row;
Label lblLastModifiedBy = (Label)e.Row.FindControl(“lblLastModified”);
if (datarow[“LastModified”].ToString() != string.Empty)
{
lblLastModified.Text = datarow[“LastModified”].ToString() + “ ”;
}
}
}