Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Arne #1
Paging and sorting
I have a datagrid that implements sorting. Once a click on a new page number,
my sort gets lost.
How can I combine sorting and paging?
Arne Guest
-
Help with simple datagrid paging and sorting issue
Please help! I have a simple web app that displays some search fields, posts back to itself onclick of the search button, and shows the results... -
Sorting and paging
I have set up numerous datagrid controls and had a recurring problem with the sorting and paging features. They simply don't work and generate and... -
DataGrid - sorting/paging problem
Hi. I have created a datagrid (datagrid1) without any columns on a aspx page. Then aspx.vb adds columns from a database. It is somthing like... -
Sorting/Paging
Brian, I've been saving the sort command to view state and then retrieving it on postback. -- S. Justin Gengo, MCP Web Developer /... -
Sorting with Paging
Hi all When I tried to implement sorting on Datagrid that has paging is sorts only the displayed page (When I navigate to another page It looses... -
steroche #2
Re: Paging and sorting
I had that problem and i think i fixed it (changed so many different
things im not sure!) by adding using the ViewState. This is what works
for me
private void dgCusomter_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
{
dgCusomter.CurrentPageIndex = e.NewPageIndex;
ViewState["CurrentPageIndex"] = e.NewPageIndex;
dgCusomter.DataBind();
dgCusomter.SelectedIndex = -1;
dgCusomter.EditItemIndex = -1;
dgCusomter.DataBind();
}
private void dgCustomer_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEvent Args e)
{
mySQLConnection sqlConn = new mySQLConnection();
this.dgGarda.CurrentPageIndex = 0;
ViewState["SortExprValue"] = e.SortExpression;
sqlComm_Customer = new SqlCommand();
sqlComm_Customer.Connection = sqlConn.GetConnection();
sqlComm_Customer.CommandText = "SELECT * FROM Customer "+
"ORDER BY "+e.SortExpression;
sqlComm_Customer.CommandType = CommandType.Text;
SqlDataAdapter daCustomer= new SqlDataAdapter(sqlComm_Customer);
daCustomer.Fill(dsCustomer);
dsCustomer.Tables[0].TableName = "Customer";
BindData();
}
Hope it does the trick!,
Steve
steroche Guest
-
Arne #3
Re: Paging and sorting
Steroche,
That is interesting. On sort, always take them to page one.
Arne.
"steroche" wrote:
> I had that problem and i think i fixed it (changed so many different
> things im not sure!) by adding using the ViewState. This is what works
> for me
>
>
> private void dgCusomter_PageIndexChanged(object source,
> System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
> {
> dgCusomter.CurrentPageIndex = e.NewPageIndex;
> ViewState["CurrentPageIndex"] = e.NewPageIndex;
> dgCusomter.DataBind();
>
> dgCusomter.SelectedIndex = -1;
> dgCusomter.EditItemIndex = -1;
>
> dgCusomter.DataBind();
> }
>
>
> private void dgCustomer_SortCommand(object source,
> System.Web.UI.WebControls.DataGridSortCommandEvent Args e)
> {
> mySQLConnection sqlConn = new mySQLConnection();
>
> this.dgGarda.CurrentPageIndex = 0;
> ViewState["SortExprValue"] = e.SortExpression;
>
> sqlComm_Customer = new SqlCommand();
>
> sqlComm_Customer.Connection = sqlConn.GetConnection();
> sqlComm_Customer.CommandText = "SELECT * FROM Customer "+
> "ORDER BY "+e.SortExpression;
> sqlComm_Customer.CommandType = CommandType.Text;
>
>
> SqlDataAdapter daCustomer= new SqlDataAdapter(sqlComm_Customer);
>
> daCustomer.Fill(dsCustomer);
> dsCustomer.Tables[0].TableName = "Customer";
> BindData();
>
>
>
> }
>
>
> Hope it does the trick!,
> Steve
>
>Arne Guest



Reply With Quote

