How to highlight an entire datagrid column?

W

wireless

Selecting a row is easy enough using the MS example:

private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType = e.Item.ItemType;
if ((itemType == ListItemType.Pager) ||
(itemType == ListItemType.Header) ||
(itemType == ListItemType.Footer))
{
return;
}
LinkButton button = (LinkButton)e.Item.Cells[0].Controls[0];
e.Item.Attributes["onclick"] =
Page.GetPostBackClientHyperlink(button, "");
}

But, how is an entire column selected?

-David
 
W

wireless

This article tells how to select a row but how is a entire column selected?

This is different from adding a select or link column to select a row.

-David

Saravana said:
Check out this article,
http://www.microsoft.com/india/msdn/articles/58.aspx

Basically you need to set the SelectedItemStyle-BackColor
to highlight the selected row.

--
Saravana
Microsoft India Community Star,MC**
www.extremeexperts.com



wireless said:
Selecting a row is easy enough using the MS example:

private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType = e.Item.ItemType;
if ((itemType == ListItemType.Pager) ||
(itemType == ListItemType.Header) ||
(itemType == ListItemType.Footer))
{
return;
}
LinkButton button = (LinkButton)e.Item.Cells[0].Controls[0];
e.Item.Attributes["onclick"] =
Page.GetPostBackClientHyperlink(button, "");
}

But, how is an entire column selected?

-David
 
P

Prasad

Hi

1. If you want to select the Column by clicking on the Column Header
what you can do is Set AllowSorting to True and based on the SortExpression
value you can determine which column select.

2. Can you be more specific abt how you want to select a Column


Prasad
 
D

David Brown

"If you want to select the Column by clicking on the Column Header what
you can do is Set AllowSorting to True and based on the SortExpression
value you can determine which column select."

Yes, I've done this just but I use sorting for sorting and need a
different column highlighted rather than the sorted one.

"2. Can you be more specific abt how you want to select a Column"

I want the user to be able to select (highlight) a column in the same
way a row is selected, that is, by clicking anywhere in the column.

-David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top