RowDataBound bool to string

L

luisrt

i have one bool value. if the value is true i want to display in my gridview "D" or the other 2 options. please help me, i know that i am missing something. but it is not working.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

if (e.Row.Cells[3] = true)
{
e.Row.Cells[3].Text = "D";
}
else
duration = new DateTime((e.Row.Cells[4].Text), 0, 0, 0);
uno = new DateTime(1, 0, 0, 0);
duration = duration + uno;
if (DateTime.Now < duration)
{
e.Row.Cells[3].Text = "A";
}
else
e.Row.Cells[3].Text = "E";
}
 
K

Kelly Leahy

Luis,

It looks like you're trying to change the value of a bound column to display
your text. If you want to display a function computed from a bound column,
you need to do so in an unbound column. In other words, create an unbound
column in your dataset or gridview and compute its "Text" property (using the
code you provided) based on the source column of the data. You can't change
the "Text" property of a bound column to a value that you DON'T want to put
in the column in that data source.

Cheers,
Kelly
 
M

MasterGaurav

Luis,

You might want to have a look at Template-d Column rather than Bound
Column whose value is not customizable.
 
M

MasterGaurav

Luis,

You might want to have a look at Template-d Column rather than Bound
Column whose value is not customizable.
 
Y

yoga weazel

I would agree with MasterGaurav. Templating is the best way to go here.
Check out TemplateField and ItemTemplate.
 

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,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top