Change the value of cell in Grid View

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.
 
M

Mark Rae [MVP]

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"; }
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top