buyteraGxfz
New Member
Im using the datalist control to display a list of products for a prototype site im building. Here is my question for any asp+ insiders or gurus that may be reading. <BR><BR>What is the most elegant way to do paging and sorting of the list. Is the Datalist control the best thing to use here. I looked at a grid but it doesnt seem to give the layout options i need like a datalist.<BR><BR>Any insight on this would be very much appreciated.<BR><BR>-MarkWell, if you want elegance, wouldn't you want to do your paging on the data tier? You know, embedding it in a SQL stored procedure to handle the paging of results, as well as a dynamically created select statement to Sort by the field of your choice? Just my 3.14159 cents...<BR><BR>But, since you asked for my help, and not my paltry sum of money, I suppose I'll have to offer that as well <BR><BR>w/ regards to sorting, according to the NGWS/.NET docs, there is a class called TemplateColumn w/ the property of SortField. Perhaps you'll want to research that more. An example syntax may be<BR><BR><asp:TemplateColumn HeaderText="Header" SortField="Field_To_Sort"><BR> <template name="ItemTemplate"><BR> <!-- template code here --><BR> </template><BR></asp:TemplateColumn><BR><BR>But, let's delve into the joy of the DataTable object (remember, you access a DataTable by using DataSet.Tables("Table_Name")<BR><BR>Right now we've been doing .DefaultView, no doubt, but believe it or not, you can pull off a filter and sort on it w/o any trouble<BR><BR>I'm gonna quote the docs for you, because I haven't tested this out.<BR><BR>DataTable.Select (String, String) [C#]<BR>Returns an array of all DataRow objects that match the filter criteria, in the the specified sort order.<BR><BR>[C#]<BR>public DataRow[] Select(<BR> string filterExpression,<BR> string sort<BR>);<BR><BR>Parameters<BR>filterExpression <BR>The criteria to use to filter the rows. <BR>sort <BR>A string specifying the column and sort direction. <BR>Return Value<BR>An array of DataRow objects matching the filter expression.<BR><BR><BR>Pst... What this means is..<BR>DataSet.Tables("Table_Name").Select("", "Sort_Field") should theorhetically be valid (and should return the rows, which would be bindable, and thus is used in leiu of .DefaultView<BR><BR>Hopefully I was some help in pointing you to the right direction... Now if only I could figure out how to change my default language on these docs... ;-)<BR><BR>God bless<BR> Ryan S<BR>