Formatting datagrid column to show boolean as Yes/no instead of truefalse

S

SStory

Is there a way to change the formatting expression of a column in the
property builder of the datagrid to make boolean values appear as yes/no
instead of true/false?

thanks,

shane
 
S

Scott Mitchell [MVP]

Is there a way to change the formatting expression of a column in the
property builder of the datagrid to make boolean values appear as yes/no
instead of true/false?

Not through the Property Builder, no. You should use a TemplateColumn
that calls a custom function that customizes the output. (Displays Yes
for True, No for False, or whatever...) See:
http://datawebcontrols.com/faqs/CustomizingAppearance/CustomizeColumnValue.shtml

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
E

Eliyahu Goldin

You can use PreRender event to go through all items and replace true/false
with yes/no.

Eliyahu
 
E

Eliyahu Goldin

In this example the column # 3 contains boolean value you want to render as
"Yes/No"

private void myGrid_PreRender(object sender, System.EventArgs e)
{
// apply PreRender rules to every row
foreach (DataGridItem item in (sender as DataGrid).Items)
{
if (item.Cells[3].Text.ToUpper() == "TRUE")
item.Cells[3].Text = "Yes";
else
item.Cells[3].Text = "No";
}
}

Eliyahu
 
S

SStory

awesome solution! Works great.

thanks,

Shane

Eliyahu Goldin said:
In this example the column # 3 contains boolean value you want to render as
"Yes/No"

private void myGrid_PreRender(object sender, System.EventArgs e)
{
// apply PreRender rules to every row
foreach (DataGridItem item in (sender as DataGrid).Items)
{
if (item.Cells[3].Text.ToUpper() == "TRUE")
item.Cells[3].Text = "Yes";
else
item.Cells[3].Text = "No";
}
}

Eliyahu
SStory said:
could you show me a little code please?

Thanks for the reply,

Shane
 
S

Saravana [MVP]

You can try this method also . Check out "Manipulating DataSource Values
while binding to DataGrid" section in the following article.
http://www.microsoft.com/india/msdn/articles/SolutionstoTopFourQuestions.asp
x


--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com



SStory said:
awesome solution! Works great.

thanks,

Shane

Eliyahu Goldin said:
In this example the column # 3 contains boolean value you want to render as
"Yes/No"

private void myGrid_PreRender(object sender, System.EventArgs e)
{
// apply PreRender rules to every row
foreach (DataGridItem item in (sender as DataGrid).Items)
{
if (item.Cells[3].Text.ToUpper() == "TRUE")
item.Cells[3].Text = "Yes";
else
item.Cells[3].Text = "No";
}
}

Eliyahu
SStory said:
could you show me a little code please?

Thanks for the reply,

Shane

You can use PreRender event to go through all items and replace true/false
with yes/no.

Eliyahu

Is there a way to change the formatting expression of a column in the
property builder of the datagrid to make boolean values appear as yes/no
instead of true/false?

thanks,

shane
 
S

SStory

Thanks.

I have found a lot of good information from the Microsoft India site.

Saravana said:
You can try this method also . Check out "Manipulating DataSource Values
while binding to DataGrid" section in the following article.
http://www.microsoft.com/india/msdn/articles/SolutionstoTopFourQuestions.asp
x


--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com



SStory said:
awesome solution! Works great.

thanks,

Shane

Eliyahu Goldin said:
In this example the column # 3 contains boolean value you want to
render
as
"Yes/No"

private void myGrid_PreRender(object sender, System.EventArgs e)
{
// apply PreRender rules to every row
foreach (DataGridItem item in (sender as DataGrid).Items)
{
if (item.Cells[3].Text.ToUpper() == "TRUE")
item.Cells[3].Text = "Yes";
else
item.Cells[3].Text = "No";
}
}

Eliyahu
could you show me a little code please?

Thanks for the reply,

Shane

You can use PreRender event to go through all items and replace
true/false
with yes/no.

Eliyahu

Is there a way to change the formatting expression of a column
in
the
property builder of the datagrid to make boolean values appear as
yes/no
instead of true/false?

thanks,

shane
 

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,020
Latest member
GenesisGai

Latest Threads

Top