Change the value of cell in Grid View

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,
From my DATABASE i get Dataset to my GRIDVIEW.
On run time I want to change the value of a cell.
For example:
Instead of "0" i want to write "N/A".

let's make it clear - I don't want to update the value in the DB
just change the specific value of the cell that the user will see on the web.

Hope I made my self clear.
 
From my DATABASE i get Dataset to my GRIDVIEW.
On run time I want to change the value of a cell.
For example:
Instead of "0" i want to write "N/A".

<asp:GridView ID="MyGridView" runat="server
OnRowDataBound="MyGridView_RowDataBound">
...
</asp:GridView>

protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[0].Text == "0") { e.Row.Cells[0].Text = "N/A"; }
}
}
 
Back
Top