Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Sorting when the page is loaded the first time

Reply
Thread Tools

Sorting when the page is loaded the first time

 
 
Patrick Jox
Guest
Posts: n/a
 
      06-30-2006
Hi,
I have am using ObjectDataSource and GridView to display data on my ASP.NET
webform. I also implemented a comparer class to be able to sort the data by
clicking on the column header.
My problem is that the first time the page is loaded the sort paramter is
passed a zero lenght string. So the gridview is not sorted.

I'm sure this is a very small thing but I can't find it:
How can I define the column that is used for sorting the first time the page
is loaded (!PostBack)?

Thanks
Patrick


 
Reply With Quote
 
 
 
 
raikinda
Guest
Posts: n/a
 
      06-30-2006

Patrick Jox yazdi:
> Hi,
> I have am using ObjectDataSource and GridView to display data on my ASP.NET
> webform. I also implemented a comparer class to be able to sort the data by
> clicking on the column header.
> My problem is that the first time the page is loaded the sort paramter is
> passed a zero lenght string. So the gridview is not sorted.
>
> I'm sure this is a very small thing but I can't find it:
> How can I define the column that is used for sorting the first time the page
> is loaded (!PostBack)?
>
> Thanks
> Patrick


Hi,
if i am not wrong, you want to sort gridview for a default column,
right? if your answer is yes, then set your selected string value one
of the columns by default. i hope that was your question!..

 
Reply With Quote
 
 
 
 
Patrick Jox
Guest
Posts: n/a
 
      06-30-2006
Hi Raikinda,
yes this is exact what I want to do. I am not sure if I understand what you
mean. But as far as I see I have done it like this.
I set the Attribute SortParameterName to SortExpression and then assigned
the value 'Height' (which is one of my columns) in the SelectParameters
section.
But still this doesn't work. Below you'll find a piece of code...

Patrick

Here is the piece of code:
<asp:ObjectDataSource ID="DisplayData" runat="server"
DeleteMethod="DeleteDisplay"
SelectMethod="GetAllDisplays"
TypeName="kapaya.smsportal.BusinessTier.Display"
SortParameterName="SortExpression">
<SelectParameters>
<asparameter Name="SortExpression" DefaultValue="Height" />
</SelectParameters>
<DeleteParameters>
<asparameter Name="Guid" />
</DeleteParameters>
</asp:ObjectDataSource>

<asp:GridView ID="DisplayList" runat="server" DataKeyNames="Guid"
AllowSorting="True"
AutoGenerateColumns="False" BorderStyle="None" CellPadding="2"
DataSourceID="DisplayData"
AllowPaging="True" BackColor="White" CssClass="Grid">
<RowStyle HorizontalAlign="Left" CssClass="row1" />
<HeaderStyle CssClass="grid-header" HorizontalAlign="Left" />
<EmptyDataTemplate>
<asp:Label ID="Label10" runat="server" Text="Label">Im Moment sind
keine Displays in der Liste anzuzeigen.</asp:Label>
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="Guid" HeaderText="Guid" SortExpression="Guid"
Visible="False"/>
<asp:BoundField DataField="Height" HeaderText="Height"
SortExpression="Height" />
<asp:BoundField DataField="Width" HeaderText="Width"
SortExpression="Width" />
<asp:BoundField DataField="Colors" HeaderText="Colors"
SortExpression="Colors" />
<asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type"
/>
<asp:CommandField DeleteImageUrl="~/images/icon-delete.gif"
ShowDeleteButton="True"
ButtonType="Image" >
<ItemStyle HorizontalAlign="Center" Width="20px" />
</asp:CommandField>

</Columns>
</asp:GridView>



"raikinda" <> schrieb im Newsbeitrag
news: oups.com...
>
> Patrick Jox yazdi:
>> Hi,
>> I have am using ObjectDataSource and GridView to display data on my
>> ASP.NET
>> webform. I also implemented a comparer class to be able to sort the data
>> by
>> clicking on the column header.
>> My problem is that the first time the page is loaded the sort paramter is
>> passed a zero lenght string. So the gridview is not sorted.
>>
>> I'm sure this is a very small thing but I can't find it:
>> How can I define the column that is used for sorting the first time the
>> page
>> is loaded (!PostBack)?
>>
>> Thanks
>> Patrick

>
> Hi,
> if i am not wrong, you want to sort gridview for a default column,
> right? if your answer is yes, then set your selected string value one
> of the columns by default. i hope that was your question!..
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Control - Check if Initialized / Being loaded for the first time???? Lucas Tam ASP .Net 0 06-22-2005 07:12 PM
Event fails to fire first time in dynamically loaded user control( =?Utf-8?B?U3RldmUgQm9vdGg=?= ASP .Net 6 04-06-2005 07:53 PM
How do I know when a user control is loaded for the first time? Alan Silver ASP .Net 2 02-24-2005 03:08 PM
java -verbose doesn't show "loaded from" for classes loaded from custom jars in the classpath Udo Corban Java 0 01-23-2004 09:32 AM
Re: how to programatically give assembly loaded from network the same trust as those loaded from local host? Marcelo Birnbach [MS] ASP .Net 0 06-27-2003 11:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57