Home All Groups Group Topic Archive Search About
Author
4 May 2006 1:16 AM
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";
}

Author
4 May 2006 4:39 AM
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

Show quoteHide quote
"lui***@runbox.com" wrote:

>
> 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";
> }
>
Are all your drivers up to date? click for free checkup

Author
4 May 2006 11:45 AM
MasterGaurav
Luis,

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


--
Cheers,
Gaurav Vaish
http://mastergaurav.org
-------------------------------
To Hell with Murphy's Law.. When things go broke, FIX Them
-------------------------------
Author
4 May 2006 11:46 AM
MasterGaurav
Luis,

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


--
Cheers,
Gaurav Vaish
http://mastergaurav.org
http://www.edujini.in
-------------------------------
To Hell with Murphy's Law.. When things go broke, FIX Them
-------------------------------
Author
5 May 2006 3:43 PM
yoga weazel
I would agree with MasterGaurav.  Templating is the best way to go here. 
Check out TemplateField and ItemTemplate.

Show quoteHide quote
"MasterGaurav" wrote:

> Luis,
>
>    You might want to have a look at Template-d Column rather than Bound
> Column whose value is not customizable.
>
>
> --
> Cheers,
> Gaurav Vaish
> http://mastergaurav.org
> http://www.edujini.in
> -------------------------------
> To Hell with Murphy's Law.. When things go broke, FIX Them
> -------------------------------
>
>

Bookmark and Share