Thursday, March 29, 2012

Paint selected cells of Datagrid

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)
rucaRuca,

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
"ruca" <ruuca@.iol.pt> wrote in message
news:%23rXtfiBxFHA.3892@.TK2MSFTNGP12.phx.gbl...
> 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
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 news:eKv8CoBxFHA.3756@.tk2msftngp13.phx.gbl...
> 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
> "ruca" <ruuca@.iol.pt> wrote in message
> news:%23rXtfiBxFHA.3892@.TK2MSFTNGP12.phx.gbl...
>> 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
>>
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" <ruuca@.iol.pt> wrote in message
news:e6uhWwBxFHA.3772@.TK2MSFTNGP11.phx.gbl...
> 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 news:eKv8CoBxFHA.3756@.tk2msftngp13.phx.gbl...
>> 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
>> "ruca" <ruuca@.iol.pt> wrote in message
>> news:%23rXtfiBxFHA.3892@.TK2MSFTNGP12.phx.gbl...
>>> 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
>>>
>>
>>
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" <justin@.[no_spam_please]aboutfortunate.com> escreveu na
mensagem news:%23GDcV$BxFHA.3588@.tk2msftngp13.phx.gbl...
> 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" <ruuca@.iol.pt> wrote in message
> news:e6uhWwBxFHA.3772@.TK2MSFTNGP11.phx.gbl...
>> 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 news:eKv8CoBxFHA.3756@.tk2msftngp13.phx.gbl...
>>> 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
>>> "ruca" <ruuca@.iol.pt> wrote in message
>>> news:%23rXtfiBxFHA.3892@.TK2MSFTNGP12.phx.gbl...
>>>> 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
>>>>
>>>
>>>
>>
>>
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" <ruuca@.iol.pt> wrote in message
news:OZjoyGCxFHA.596@.TK2MSFTNGP12.phx.gbl...
> 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" <justin@.[no_spam_please]aboutfortunate.com> escreveu na
> mensagem news:%23GDcV$BxFHA.3588@.tk2msftngp13.phx.gbl...
>> 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" <ruuca@.iol.pt> wrote in message
>> news:e6uhWwBxFHA.3772@.TK2MSFTNGP11.phx.gbl...
>>> 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 news:eKv8CoBxFHA.3756@.tk2msftngp13.phx.gbl...
>>>> 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
>>>> "ruca" <ruuca@.iol.pt> wrote in message
>>>> news:%23rXtfiBxFHA.3892@.TK2MSFTNGP12.phx.gbl...
>>>>> 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
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>

0 comments:

Post a Comment