How to make Row_DataBound in GridView work all the time?

J

JB

Hello Community

Using ASP.NET and C# with Sql Server in the back end I have a GridView that
uses Row_DataBound event on a web page. When one of the columns contains a
letter in the database such as “N†or “Y†that column in the GridView shows
“No†or “Yes†using Row_DataBound.

This works fine initially but after modifying a row in the database the “Nâ€
or “Y†doesn’t show the “No†or “Yes†in the GridView when the page comes
back but instead still shows the “N†or “Y†in the GridView that is
literally in the database until I add another record, then it will go back to
showing the “No†or “Yes†in the GridView as directed by the Row_DataBound
event when the page show again.

Is there a way to make the Row_DataBound event always show “No†or “Yes†in
the GridView for the N†or “Y†that is in the database column ?

When does this GridView actually respond to actions on the web page?

Below is a similar to the Row_DataBound event :

protected void grid1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int inRow = grid1.Rows.Count;
if (ddlPipes.SelectedIndex < 1)
{
return;
}
if (grid1.Rows.Count == 0)
{
return;
}
GridViewRow gRow
gRow = e.Row;
if (gRow.RowType == DataControlRowType.DataRow)
gRow.Cells[4].Text = grid1.Cells[4].Text.Equals("Y") ? "Yes" : "No";
}

Thanks
Jeff
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top