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

arameter Name="SortExpression" DefaultValue="Height" />
</SelectParameters>
<DeleteParameters>
<asp

arameter 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!..
>