Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > sorting in a datagrid

Reply
Thread Tools

sorting in a datagrid

 
 
Julia
Guest
Posts: n/a
 
      06-12-2006
Hi,

I am developing a composite control, so I am writing all my code in a *.cs
file. One of the component in my composite control is a datagrid. The
datagrid is populated from a dataview by using DataBind(). The user should be
able to sort the datagrid my clicking the header of the columns. Anyone has
a sample of this? It would be really helpful for me. I only want to write c#
code to do this.

Thanks
Julia
 
Reply With Quote
 
 
 
 
Julia
Guest
Posts: n/a
 
      06-12-2006
Hi

It is working when I use AutoGenerateColumns = true; but not when I use
AutoGenerateColumns = false;.

Any ideas?

/Julia

"Julia" wrote:

> Hi,
>
> I am developing a composite control, so I am writing all my code in a *.cs
> file. One of the component in my composite control is a datagrid. The
> datagrid is populated from a dataview by using DataBind(). The user should be
> able to sort the datagrid my clicking the header of the columns. Anyone has
> a sample of this? It would be really helpful for me. I only want to write c#
> code to do this.
>
> Thanks
> Julia

 
Reply With Quote
 
 
 
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      06-13-2006
hi Julia,
you need to attach to the SortCommand handler for your datagrid in code and
then do what you need to do in this event when sorting is enabled on the
grid. One possible mistake i can think of why you sorting is not working on
your grid is possibly because when you set autogenerate columns to false,
you are probably also trying to set a templatecolumn in the HeaderTemplate
<HeaderTemplate></HeaderTemplate> . In this case make sure you add a control
in your HeaderTemplate that can postback like a button control or a
linkbutton, imagebutton etc..
try these resources :
http://msdn2.microsoft.com/en-us/lib...owsorting.aspx

http://msdn2.microsoft.com/en-us/lib...rtcommand.aspx

good luck,
Alessandro Zifiglio
"Julia" <(E-Mail Removed)> ha scritto nel messaggio
news:(E-Mail Removed)...
> Hi
>
> It is working when I use AutoGenerateColumns = true; but not when I use
> AutoGenerateColumns = false;.
>
> Any ideas?
>
> /Julia
>
> "Julia" wrote:
>
>> Hi,
>>
>> I am developing a composite control, so I am writing all my code in a
>> *.cs
>> file. One of the component in my composite control is a datagrid. The
>> datagrid is populated from a dataview by using DataBind(). The user
>> should be
>> able to sort the datagrid my clicking the header of the columns. Anyone
>> has
>> a sample of this? It would be really helpful for me. I only want to write
>> c#
>> code to do this.
>>
>> Thanks
>> Julia



 
Reply With Quote
 
Riki
Guest
Posts: n/a
 
      06-13-2006
If you're using BoundColumns, don't forget to set the SortExpression
property for each column.

--

Riki

"Julia" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> It is working when I use AutoGenerateColumns = true; but not when I use
> AutoGenerateColumns = false;.
>
> Any ideas?
>
> /Julia
>
> "Julia" wrote:
>
>> Hi,
>>
>> I am developing a composite control, so I am writing all my code in a
>> *.cs
>> file. One of the component in my composite control is a datagrid. The
>> datagrid is populated from a dataview by using DataBind(). The user
>> should be
>> able to sort the datagrid my clicking the header of the columns. Anyone
>> has
>> a sample of this? It would be really helpful for me. I only want to write
>> c#
>> code to do this.
>>
>> Thanks
>> Julia



 
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
Sorting list vs sorting vector boltar2003@boltar.world C++ 2 07-06-2010 09:40 AM
fired event Sorting which wasn't handled - sorting and SelectedIndexChanged Jason ASP .Net Web Controls 0 10-04-2006 02:19 PM
[Datagrid,web form]: How the get the correct row values after sorting datagrid by header AlainCD ASP .Net Datagrid Control 0 01-12-2006 09:07 AM
sorting by multiple criterias (sub-sorting) Tom Kirchner Perl Misc 3 10-11-2003 05:16 PM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM



Advertisments