Paint selected cells of Datagrid

R

ruca

Hi,

Can anyone give me examples of how can I hightlight cells of my datagrid? I
know that I must use ItemBound event and probably JavaScript.

The thing is that I have a anual calendar, constructed in a DataGrid. Then
what I want is select a range of two dates in that same calendar to do any
action.


Can anyone gives me examples??????
 
R

ruca

Hi,

Thank's, but it is not whta I really want.
I want to select single cells (but they must be followed) and paint them
selfs.
 
S

S. Justin Gengo

Ruca,

Do you mean you want to be able to hover over (or click) on a cell
clientside and have it highlight?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
R

ruca

Justin,

Yes, something like that. But the cells must be followed, because we are
talking about select days of a calendar.
 
S

S. Justin Gengo

In that case use the item databound event to add a onmouseover javascript to
each cell.

The script will need to have an if then that checks the current value and
set's it to the opposite value on mouse over.

I have some simlar code:

1.. Private Sub DataGrid1_ItemDataBound(ByVal sender As System.Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
2.. Try
3.. Dim itemType As ListItemType = e.Item.ItemType
4..
5.. If ((itemType = ListItemType.Pager) Or (itemType =
ListItemType.Header) Or (itemType = ListItemType.Footer)) Then
6.. Return
7.. Else
8.. '---You'll have to change the code that get's the link button to
reflect the proper zero based column index:
9.. Dim button As LinkButton = CType(e.Item.Cells(3).Controls(0),
LinkButton)
10.. e.Item.Attributes("onClick") =
Page.GetPostBackClientHyperlink(button, "")
11..
12.. '---Note that I've used javascript to show the cursor as a pointer
when a row is hovered over so that users will know it's clickable.
13.. e.Item.Attributes.Add("onMouseOver",
"javascript:this.style.cursor='pointer';")
14.. e.Item.Attributes.Add("omMouseOut",
"javascript:this.style.cursor='normal';")
15.. End If
16.. Catch ex As Exception
17.. '---Handle Exception
18.. End Try
19.. End Sub
It's the onmouseover portion you'll want to pay attention to. Also, this
code is adding the javascript to the entire row. You'll want to specify
adding it to each cell within e.Item (e.Item is the row).

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
ruca said:
Justin,

Yes, something like that. But the cells must be followed, because we are
talking about select days of a calendar.


--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca


S. Justin Gengo said:
Ruca,

Do you mean you want to be able to hover over (or click) on a cell
clientside and have it highlight?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
ruca said:
Hi,

Thank's, but it is not whta I really want.
I want to select single cells (but they must be followed) and paint them
selfs.



--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> escreveu
na mensagem Ruca,

See if this article helps:

http://www.codeproject.com/aspnet/PrettyDatagrids.asp

One part of it show how to highlight single cells based on data values

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Hi,

Can anyone give me examples of how can I hightlight cells of my
datagrid? I know that I must use ItemBound event and probably
JavaScript.

The thing is that I have a anual calendar, constructed in a DataGrid.
Then what I want is select a range of two dates in that same calendar
to do any action.


Can anyone gives me examples??????




--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top