Gridview Questions
-
I display some boolean values in checkboxes. Is it possible instead of the checkboxes the values to displayed as On if the database cell=True or Off if the value=False. Also if all the values in a column are the same e.g kjaslklkajl. Is it possible to represent this colunm with different value? kjaslklkajl=Some Name. Thanks
-
I display some boolean values in checkboxes. Is it possible instead of the checkboxes the values to displayed as On if the database cell=True or Off if the value=False. Also if all the values in a column are the same e.g kjaslklkajl. Is it possible to represent this colunm with different value? kjaslklkajl=Some Name. Thanks
How come you are displaying values in the checkboxes? U'r question is not clear ...
Koushik
-
I display some boolean values in checkboxes. Is it possible instead of the checkboxes the values to displayed as On if the database cell=True or Off if the value=False. Also if all the values in a column are the same e.g kjaslklkajl. Is it possible to represent this colunm with different value? kjaslklkajl=Some Name. Thanks
HI, Make autogeneratecolumns property of gridview to false. and create for each of the column you need to display. This way your boolean column will display "True" and "False" in the gridview. Now you can change this to "On" and "Off" by writing code in the "RowDataBound" event of the gridview. protected void gvDemo_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.Cells[2].Text == "True") { e.Row.Cells[2].Text = "On"; } else { e.Row.Cells[2].Text = "Off"; } } } set OnRowDataBound = "gvDemo_RowDataBound" in the gridview. The code for your sencond problem can also be written here only cellindex will be changed. I hope this will help you. Thanks and Regards, Chetan Ranpariya
-
HI, Make autogeneratecolumns property of gridview to false. and create for each of the column you need to display. This way your boolean column will display "True" and "False" in the gridview. Now you can change this to "On" and "Off" by writing code in the "RowDataBound" event of the gridview. protected void gvDemo_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.Cells[2].Text == "True") { e.Row.Cells[2].Text = "On"; } else { e.Row.Cells[2].Text = "Off"; } } } set OnRowDataBound = "gvDemo_RowDataBound" in the gridview. The code for your sencond problem can also be written here only cellindex will be changed. I hope this will help you. Thanks and Regards, Chetan Ranpariya