Datalist Control

Results 1 to 2 of 2

Thread: Datalist Control

  1. #1
    Mark Guest

    Default Datalist Control

    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>-Mark

  2. #2
    Ryan ( Guest

    Default RE: Datalist Control

    Well, if you want elegance, wouldn&#039t 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&#039ll 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&#039ll want to research that more. An example syntax may be<BR><BR>&#060;asp:TemplateColumn HeaderText="Header" SortField="Field_To_Sort"&#062;<BR> &#060;template name="ItemTemplate"&#062;<BR> &#060;!-- template code here --&#062;<BR> &#060;/template&#062;<BR>&#060;/asp:TemplateColumn&#062;<BR><BR>But, let&#039s delve into the joy of the DataTable object (remember, you access a DataTable by using DataSet.Tables("Table_Name")<BR><BR>Right now we&#039ve 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&#039m gonna quote the docs for you, because I haven&#039t 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>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts