Make autogeneratecolumns property of gridview to false.
and create <asp:BoundField> 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.Text == "True")
e.Row.Cells.Text = "On";
e.Row.Cells.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 have a problem and I didnt find an aswer into articles.
I have a datalist, a sqldatasource and a page.
I should select some data from database and display it on the page using datalist.
I can do it.
But i should add a footer for navigation into my datalist beacause when page loaded datalist has ALL rows from query but it must be dispalying only for 20 rows on the first page, 20 on the next page e.t.c. and I would like change current page (like in a gridview).
I cant use gridview because my items should be displaing like:
hi,i have one doubt regarding page class methods.my doubt is when to use RegisterStartupScript() and RegisterClientScriptBlock() methods.what is the major difference between the two methods?.please give suggestions for where those best suited.
I Don't know much about this two except
The RegisterClientScriptBlock method adds a script block to the top of the rendered page.
The script block added by the RegisterStartupScript method executes when the page finishes loading but before the page's OnLoad event is raised.
Thanks and Regards Sandeep
If you want something you never had,
do something you have never done!
SqlConnection myConnection =
new SqlConnection(connstring );
SqlDataAdapter myAdapter =
"SELECT ProductID, ProductName, QuantityPerUnit, UnitPrice FROM Products",
//Fill the DataSet
DataSet ds = new DataSet();
//DataBind the Repeater
// MyRepeater.DataSource = ds.Tables["Products"].DefaultView;
// Populate the repeater control with the Items DataSet
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables.DefaultView;
objPds.AllowPaging = true;
objPds.CurrentPageIndex = CurrentPage;
I tmeans that the first table in the dataset is to be attached to the datasource of the control...DefaultView property returns a DataView you can use to sort, filter, and search a DataTable...
for eg... ds.Tables.DefaultView.RowFilter = "city='New York'"