How to work with Grid view

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() + “&nbsp;”;
}

}

}

Advertisements

About kakani santosh kumar

Working as Software Engineer in Prithvi Information Solutions having 3 years of Experience in Dotnet Framework ranging from 1.1 to 3.5
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s