CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.faq_frequently_asked_questions Tags:
Item Type: NewsGroup Date Entered: 1/24/2006 6:55:57 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 185 Views: 237 Favorited: 0 Favorite
186 Items, 10 Pages 1 2 3 4 5 6 7 8 9 10 |< << Go >> >|
krishanmanral
Asp.Net User
Re: HOW TO: Using sorting / paging on GridView w/o a DataSourceControl DataSource7/27/2007 5:57:38 AM

0

i m having problem that when i select any header item for sorting i got the same result of sortdirection = acsending every time.

 

ConvertSortDirectionToSql function alwawys returns "Asc" what should i do next

krishanmanral
Asp.Net User
Re: HOW TO: Using sorting / paging on GridView w/o a DataSourceControl DataSource7/27/2007 5:58:42 AM

0

i m having problem that when i select any header item for sorting i got the same result of sortdirection = acsending every time.

 

ConvertSortDirectionToSql function alwawys returns "Asc" what should i do next

 

my code is as below

 

private string ConvertSortDir(SortDirection sortDireciton)

{

string newSortDirection = String.Empty;switch (sortDireciton)

{

case SortDirection.Ascending:

newSortDirection = "ASC";

break;

case SortDirection.Descending:

newSortDirection = "DESC";

break;

}

return newSortDirection;

}

protected void grdvwdesignmaster_Sorting(object sender, GridViewSortEventArgs e)

{

DataTable objds1 = (DataTable)Session["desmas"];if (objds1 != null)

{

DataView dataView = new DataView(objds1);

dataView.Sort = e.SortExpression + " " + ConvertSortDir(e.SortDirection);

grdvwdesignmaster.DataSource = dataView;

grdvwdesignmaster.DataBind();

}

}

osmanmz
Asp.Net User
Re: HOW TO: Using sorting / paging on GridView w/o a DataSourceControl DataSource7/27/2007 7:00:42 AM

0

Hi

Store your sort direction in a viewStateVariable.

Save the last direction once you're completed sorting.  I've used three states below:  ASC, DESC, unsorted:

 (In "grdvwdesignmaster_Sorting" change

"dataView.Sort = e.SortExpression + " " + ConvertSortDir(e.SortDirection); "

to:

if (GridViewSortDirection.Length > 0)

{

dataView.Sort = e.SortExpression + " " + GridViewSortDirection;

}

ChangeSortDirection();

 

ViewState property & function:

private string GridViewSortDirection

{

get { return ViewState["SortDirection"] as string ?? "ASC"; }

set { ViewState["SortDirection"] = value; }

}

 

 private string ChangeSortDirection()

{

switch (GridViewSortDirection)

{

case "ASC":

GridViewSortDirection = "DESC";

break;

case "DESC":

GridViewSortDirection = "";

break;

default:

GridViewSortDirection = "ASC";

break;

}

return GridViewSortDirection;

}

}

private string GridViewSortDirection

{

get { return ViewState["SortDirection"] as string ?? "ASC"; }

set { ViewState["SortDirection"] = value; }

}

shakthi_001
Asp.Net User
Re: HOW TO: Using sorting / paging on GridView w/o a DataSourceControl DataSource7/27/2007 4:30:37 PM

0

 Hi Ryan thx for the post......i copied the code(GridView Sorting/Paging w/o a DataSourceControl DataSource)and it was working gr8.....but i moved the PopulatePublishersGridView() from page load to Button_Click.....Once i click the button i can see the Grid.....but if try clicking header text for sorting iam getting an message "NO DATA FOUND".....even if i click page number same error...but every thing was fine if it is in page_load......can plz tell me the problem...................thank you

krishanmanral
Asp.Net User
Re: HOW TO: Using sorting / paging on GridView w/o a DataSourceControl DataSource7/30/2007 6:40:10 AM

0

thanks it works for me
krishanmanral
Asp.Net User
Re: HOW TO: Using sorting / paging on GridView w/o a DataSourceControl DataSource7/30/2007 6:56:02 AM

0

thank you very much it works for me
186 Items, 10 Pages 1 2 3 4 5 6 7 8 9 10 |< << Go >> >|


Free Download:




   
  Privacy | Contact Us
All Times Are GMT