DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Getting Access To Cell Contents Within Your GridView

09.07.2006
| 14484 views |
  • submit to reddit
        Add OnRowDataBound = "RowDataBound" to your GridView control on your ASP.NET page
Add the below code to your code-behind page

public void RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.DataItemIndex > -1)
    {
        e.Row.Cells[0].Text = string.Format("{0,C}", e.Row.Cells[0].Text);
    }
}