Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > sort image or style on data grid

Reply
Thread Tools

sort image or style on data grid

 
 
Brian Henry
Guest
Posts: n/a
 
      07-14-2004
is there a way to put a style or marker image on the header of a data grid
in asp.net to mark that this is the column being sorted on? thanks


 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-14-2004
Hi Brian,

As for your questions on marking a certain columns' header in webform
datagrid when the certain columns is being sorted on, here are my
suggestions:

All the WebForm DataGrid's Column are dervied from the
System.Web.UI.WebControl.DataGridColumn base class. This class has three
properties which can help set the column's header style feature, they are

HeaderImageUrl========== Gets or sets the location of an image to display
in the header section of the column.

HeaderStyle ============Gets the style properties for the header section of
the column.

HeaderText============ Gets or sets the text displayed in the header
section of the column.

Here is the reference in MSDN:
#DataGridColumn Properties
http://msdn.microsoft.com/library/en...WebUIWebContro
lsDataGridColumnPropertiesTopic.asp?frame=true

And the "HeaderStyle" property is especially good since it contains many
sub members such as BackColor or BorderColor....

Thus, in the DataGrid's SortCommand event, we can retrieve the certain
columns reference from the
DataGrid.Columns collection and set any of the above three properties of
the sorted column. How do you think of this?


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx




 
Reply With Quote
 
 
 
 
Brian Henry
Guest
Posts: n/a
 
      07-14-2004
I know about the properties of the column header, but how I get which column
it is working with from the sort event I'm not sure of


"Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Brian,
>
> As for your questions on marking a certain columns' header in webform
> datagrid when the certain columns is being sorted on, here are my
> suggestions:
>
> All the WebForm DataGrid's Column are dervied from the
> System.Web.UI.WebControl.DataGridColumn base class. This class has three
> properties which can help set the column's header style feature, they are
>
> HeaderImageUrl========== Gets or sets the location of an image to display
> in the header section of the column.
>
> HeaderStyle ============Gets the style properties for the header section

of
> the column.
>
> HeaderText============ Gets or sets the text displayed in the header
> section of the column.
>
> Here is the reference in MSDN:
> #DataGridColumn Properties
>

http://msdn.microsoft.com/library/en...WebUIWebContro
> lsDataGridColumnPropertiesTopic.asp?frame=true
>
> And the "HeaderStyle" property is especially good since it contains many
> sub members such as BackColor or BorderColor....
>
> Thus, in the DataGrid's SortCommand event, we can retrieve the certain
> columns reference from the
> DataGrid.Columns collection and set any of the above three properties of
> the sorted column. How do you think of this?
>
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx
>
>
>
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-15-2004
Hi Brian,

Thanks for your response. As for how to get the column that is on sorting
in SortEvent, this is done by the
System.Web.UI.WebControls.DataGridSortCommandEvent Args e
argument pass into the DataGrid's SortCommand event,
it contains a member property called "SortExpression", this field just
contains the
"SortExpression" of the certain Column which is being sorted. We can set
the "SortExpression" of each column in datagrid at design time.

#DataGridColumn.SortExpression Property
http://msdn.microsoft.com/library/en...WebUIWebContro
lsDataGridColumnClassSortExpressionTopic.asp?frame =true

And here are some related reference in MSDN on using the Datagrid's sort
feature:

#DataGrid.SortCommand Event
http://msdn.microsoft.com/library/en...webuiwebcontro
lsdatagridclasssortcommandtopic.asp?frame=true

#Adding Sorting to a DataGrid Web Server Control
http://msdn.microsoft.com/library/en...SortingToDataG
ridWebControl.asp?frame=true


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

 
Reply With Quote
 
Joe Fallon
Guest
Posts: n/a
 
      07-15-2004
You can inject a Label control after the Header text control of the Sort
column.
Use the Item Data Bound event for this.
The label will just display " 5" or " 6". The space gives you a little
separation fromthe header text.
But the Font is Wingdings, x-small.
(this gives you an up or down triangle.)

I don't have any code samples handy but I use this trick and it works
nicely.
--
Joe Fallon



"Brian Henry" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> is there a way to put a style or marker image on the header of a data grid
> in asp.net to mark that this is the column being sorted on? thanks
>
>



 
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
Sort Event does not fire when EnableViewState =false for data grid =?Utf-8?B?VmlkZHM=?= ASP .Net 1 10-09-2007 12:15 PM
Data Grid Sort Problem thebison ASP .Net 1 04-10-2006 05:15 AM
Need help with Style conversion from Style object to Style key/value collection. Ken Varn ASP .Net Building Controls 0 04-26-2004 07:06 PM
Sort Dynamic Data Grid Amy Snyder ASP .Net 0 12-02-2003 03:01 PM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM



Advertisments