display a string in GridView istead of DB value
-
Hi I have a probably quite easy question but which drives me crazy! I am using a Gridview in my web page. I bind with a sqldatasource and gridview displays all data correctly. But i want gridview to display an another string instead of the data in database. For example : There is a field named "isexists" in my table having 1 or 0 data. But on the web page , i want to show that column data as "YES" (instead of 1) and "NO" (instead of 0) in gridview. Could you please help me about this? Thanks and Regards mcbulan
-
Hi I have a probably quite easy question but which drives me crazy! I am using a Gridview in my web page. I bind with a sqldatasource and gridview displays all data correctly. But i want gridview to display an another string instead of the data in database. For example : There is a field named "isexists" in my table having 1 or 0 data. But on the web page , i want to show that column data as "YES" (instead of 1) and "NO" (instead of 0) in gridview. Could you please help me about this? Thanks and Regards mcbulan
mustafa bulan wrote:
But on the web page , i want to show that column data as "YES" (instead of 1) and "NO" (instead of 0) in gridview.
Either you can do this in the query or in
row_databound
event of GridView. In this event check the value, if value is 0 set the cells text as "NO" else "YES".All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
mustafa bulan wrote:
But on the web page , i want to show that column data as "YES" (instead of 1) and "NO" (instead of 0) in gridview.
Either you can do this in the query or in
row_databound
event of GridView. In this event check the value, if value is 0 set the cells text as "NO" else "YES".All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
thankx for your reply.:rose: but how i check the current value at that record? i need to know some codes like : // rowdatabound event if gridview1.rows(?).cells(??).text = "1" then gridview1.rows(?).cells(??).text = "YES" else gridview1.rows(?).cells(??).text = "NO" :^)
-
mustafa bulan wrote:
But on the web page , i want to show that column data as "YES" (instead of 1) and "NO" (instead of 0) in gridview.
Either you can do this in the query or in
row_databound
event of GridView. In this event check the value, if value is 0 set the cells text as "NO" else "YES".All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
I have been doing similar checks using functions and the Eval keyword... i.e.
...Text='<%# ACunningFunction(Eval("db_field_name")) %>'
Which would require something like:
protected string ACunningFunction(object db_field)
{
//Check your db_field here and return an appropriate string
}Are there any performance implications in doing it this way?
-
I have been doing similar checks using functions and the Eval keyword... i.e.
...Text='<%# ACunningFunction(Eval("db_field_name")) %>'
Which would require something like:
protected string ACunningFunction(object db_field)
{
//Check your db_field here and return an appropriate string
}Are there any performance implications in doing it this way?
This is a fair approach and I don't think about any performance issues.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
thankx for your reply.:rose: but how i check the current value at that record? i need to know some codes like : // rowdatabound event if gridview1.rows(?).cells(??).text = "1" then gridview1.rows(?).cells(??).text = "YES" else gridview1.rows(?).cells(??).text = "NO" :^)
RowDatabound has two arguments object and events e you can go by e.cells("").value