ASP.NET GridView second header row to span main header row

I took the accepted answer approach, but added the header to the existing GridView instead of a custom inherited GridView. After I bind my GridView, I do the following: /*Create header row above generated header row*/ //create row GridViewRow row = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal); //spanned cell that will span the columns I don’t … Read more

sorting and paging with gridview asp.net

Save your sorting order in a ViewState. private const string ASCENDING = ” ASC”; private const string DESCENDING = ” DESC”; public SortDirection GridViewSortDirection { get { if (ViewState[“sortDirection”] == null) ViewState[“sortDirection”] = SortDirection.Ascending; return (SortDirection) ViewState[“sortDirection”]; } set { ViewState[“sortDirection”] = value; } } protected void GridView_Sorting(object sender, GridViewSortEventArgs e) { string sortExpression = … Read more

Change header text of columns in a GridView

You should do that in GridView’s RowDataBound event which is triggered for every GridViewRow after it was databound. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { e.Row.Cells[0].Text = “Date”; } } or you can set AutogenerateColumns to false and add the columns declaratively on aspx: <asp:gridview id=”GridView1″ onrowdatabound=”GridView1_RowDataBound” autogeneratecolumns=”False” emptydatatext=”No data … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)