473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

why will this not work in C#

What i'm trying to do is allow the user click on a row in the datagrid and it
highlights the row. I have the select button for my grid and its hidden.
I can do this in VB.NET successfully with this same code but when i put it
in C# it does not work.

what am i missing?

private void DataGrid1_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item | e.Item.ItemType ==
ListItemType.AlternatingItem | e.Item.ItemType == ListItemType.SelectedItem)
{
e.Item.Attributes.Add("onmouseover",
"this.style.bacgroundcolor='#FFFFFF';this.style.cu rsor='hand'");
e.Item.Attributes.Add("onclick","javascript:__doPo stBack('" + " DataGrid1:"
+ "_ctl" + (e.Item.ItemIndex + 7) + ":_ctl0','')");

}
}
Nov 18 '05 #1
6 1159
Mike wrote:
What i'm trying to do is allow the user click on a row in the
datagrid and it highlights the row. I have the select button for my
grid and its hidden.
I can do this in VB.NET successfully with this same code but when i
put it in C# it does not work.

what am i missing?

private void DataGrid1_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item | e.Item.ItemType ==
ListItemType.AlternatingItem | e.Item.ItemType ==
ListItemType.SelectedItem) {
e.Item.Attributes.Add("onmouseover",
"this.style.bacgroundcolor='#FFFFFF';this.style.cu rsor='hand'");
e.Item.Attributes.Add("onclick","javascript:__doPo stBack('" + "
DataGrid1:" + "_ctl" + (e.Item.ItemIndex + 7) + ":_ctl0','')");

}
}


What exactly do you mean by "does not work"?

One thing I notice: you use "|", which is C# for "bitwise OR"
(with integer oparands).
I think you want "||" (C# for "boolean OR") (with boolean operands)

Hans Kesting
Nov 18 '05 #2
It doesn't work. It does not allow me to click on a row and highlight the
row, like it does in the VB.NET world.
"Hans Kesting" wrote:
Mike wrote:
What i'm trying to do is allow the user click on a row in the
datagrid and it highlights the row. I have the select button for my
grid and its hidden.
I can do this in VB.NET successfully with this same code but when i
put it in C# it does not work.

what am i missing?

private void DataGrid1_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item | e.Item.ItemType ==
ListItemType.AlternatingItem | e.Item.ItemType ==
ListItemType.SelectedItem) {
e.Item.Attributes.Add("onmouseover",
"this.style.bacgroundcolor='#FFFFFF';this.style.cu rsor='hand'");
e.Item.Attributes.Add("onclick","javascript:__doPo stBack('" + "
DataGrid1:" + "_ctl" + (e.Item.ItemIndex + 7) + ":_ctl0','')");

}
}


What exactly do you mean by "does not work"?

One thing I notice: you use "|", which is C# for "bitwise OR"
(with integer oparands).
I think you want "||" (C# for "boolean OR") (with boolean operands)

Hans Kesting

Nov 18 '05 #3
Mike wrote:
It doesn't work. It does not allow me to click on a row and highlight
the row, like it does in the VB.NET world.

Is the mouseover code added (see html-source in the browser)? (probably not)

Did you change | to || (double-pipe) in your code?

Hans Kesting

"Hans Kesting" wrote:
Mike wrote:
What i'm trying to do is allow the user click on a row in the
datagrid and it highlights the row. I have the select button for my
grid and its hidden.
I can do this in VB.NET successfully with this same code but when i
put it in C# it does not work.

what am i missing?

private void DataGrid1_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item | e.Item.ItemType ==
ListItemType.AlternatingItem | e.Item.ItemType ==
ListItemType.SelectedItem) {
e.Item.Attributes.Add("onmouseover",
"this.style.bacgroundcolor='#FFFFFF';this.style.cu rsor='hand'");
e.Item.Attributes.Add("onclick","javascript:__doPo stBack('" + "
DataGrid1:" + "_ctl" + (e.Item.ItemIndex + 7) + ":_ctl0','')");

}
}


What exactly do you mean by "does not work"?

One thing I notice: you use "|", which is C# for "bitwise OR"
(with integer oparands).
I think you want "||" (C# for "boolean OR") (with boolean operands)

Hans Kesting

Nov 18 '05 #4
yes its in the code and yes I added the || (which made no difference)
"Hans Kesting" wrote:
Mike wrote:
It doesn't work. It does not allow me to click on a row and highlight
the row, like it does in the VB.NET world.


Is the mouseover code added (see html-source in the browser)? (probably not)

Did you change | to || (double-pipe) in your code?

Hans Kesting

"Hans Kesting" wrote:
Mike wrote:
What i'm trying to do is allow the user click on a row in the
datagrid and it highlights the row. I have the select button for my
grid and its hidden.
I can do this in VB.NET successfully with this same code but when i
put it in C# it does not work.

what am i missing?

private void DataGrid1_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item | e.Item.ItemType ==
ListItemType.AlternatingItem | e.Item.ItemType ==
ListItemType.SelectedItem) {
e.Item.Attributes.Add("onmouseover",
"this.style.bacgroundcolor='#FFFFFF';this.style.cu rsor='hand'");
e.Item.Attributes.Add("onclick","javascript:__doPo stBack('" + "
DataGrid1:" + "_ctl" + (e.Item.ItemIndex + 7) + ":_ctl0','')");

}
}

What exactly do you mean by "does not work"?

One thing I notice: you use "|", which is C# for "bitwise OR"
(with integer oparands).
I think you want "||" (C# for "boolean OR") (with boolean operands)

Hans Kesting


Nov 18 '05 #5
Mike wrote:
yes its in the code and yes I added the || (which made no difference)


Then I don't know, apart from something I noticed just now:
you write "bacgroundcolor" in your post, which should be "backgroundcolor"
(but this is probably just a typo in your post)

Hans Kesting

"Hans Kesting" wrote:
Mike wrote:
It doesn't work. It does not allow me to click on a row and
highlight the row, like it does in the VB.NET world.


Is the mouseover code added (see html-source in the browser)?
(probably not)

Did you change | to || (double-pipe) in your code?

Hans Kesting

"Hans Kesting" wrote:

Mike wrote:
> What i'm trying to do is allow the user click on a row in the
> datagrid and it highlights the row. I have the select button for
> my grid and its hidden.
> I can do this in VB.NET successfully with this same code but when
> i put it in C# it does not work.
>
> what am i missing?
>
> private void DataGrid1_ItemCreated(object sender,
> System.Web.UI.WebControls.DataGridItemEventArgs e)
> {
> if(e.Item.ItemType == ListItemType.Item | e.Item.ItemType ==
> ListItemType.AlternatingItem | e.Item.ItemType ==
> ListItemType.SelectedItem) {
> e.Item.Attributes.Add("onmouseover",
> "this.style.bacgroundcolor='#FFFFFF';this.style.cu rsor='hand'");
> e.Item.Attributes.Add("onclick","javascript:__doPo stBack('" + "
> DataGrid1:" + "_ctl" + (e.Item.ItemIndex + 7) + ":_ctl0','')");
>
> }
> }

What exactly do you mean by "does not work"?

One thing I notice: you use "|", which is C# for "bitwise OR"
(with integer oparands).
I think you want "||" (C# for "boolean OR") (with boolean operands)

Hans Kesting

Nov 18 '05 #6
I got it working thx

"Hans Kesting" wrote:
Mike wrote:
yes its in the code and yes I added the || (which made no difference)


Then I don't know, apart from something I noticed just now:
you write "bacgroundcolor" in your post, which should be "backgroundcolor"
(but this is probably just a typo in your post)

Hans Kesting

"Hans Kesting" wrote:
Mike wrote:
It doesn't work. It does not allow me to click on a row and
highlight the row, like it does in the VB.NET world.
Is the mouseover code added (see html-source in the browser)?
(probably not)

Did you change | to || (double-pipe) in your code?

Hans Kesting
"Hans Kesting" wrote:

> Mike wrote:
>> What i'm trying to do is allow the user click on a row in the
>> datagrid and it highlights the row. I have the select button for
>> my grid and its hidden.
>> I can do this in VB.NET successfully with this same code but when
>> i put it in C# it does not work.
>>
>> what am i missing?
>>
>> private void DataGrid1_ItemCreated(object sender,
>> System.Web.UI.WebControls.DataGridItemEventArgs e)
>> {
>> if(e.Item.ItemType == ListItemType.Item | e.Item.ItemType ==
>> ListItemType.AlternatingItem | e.Item.ItemType ==
>> ListItemType.SelectedItem) {
>> e.Item.Attributes.Add("onmouseover",
>> "this.style.bacgroundcolor='#FFFFFF';this.style.cu rsor='hand'");
>> e.Item.Attributes.Add("onclick","javascript:__doPo stBack('" + "
>> DataGrid1:" + "_ctl" + (e.Item.ItemIndex + 7) + ":_ctl0','')");
>>
>> }
>> }
>
> What exactly do you mean by "does not work"?
>
> One thing I notice: you use "|", which is C# for "bitwise OR"
> (with integer oparands).
> I think you want "||" (C# for "boolean OR") (with boolean operands)
>
> Hans Kesting


Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: Antoon Pardon | last post by:
I have had a look at the signal module and the example and came to the conclusion that the example wont work if you try to do this in a thread. So is there a chance similar code will work in a...
7
by: jason | last post by:
I am getting twisted by the possibility that my virtual includes which currently work great on non-domain remote IP will crash if I purchase a domain and point it to one of my designated...
8
by: Eric Lilja | last post by:
Hello, I had what I thought was normal text-file and I needed to locate a string matching a certain pattern in that file and, if found, replace that string. I thought this would be simple but I had...
3
by: Zheng Da | last post by:
Will the following class work well? If it can not work correctly in some situation, could you help me to fix it? Thank you. //the class will work like the reference in java //when you create a...
5
by: Ralph2 | last post by:
Hello The person responsible for installing software at work believes in installing the bare minimum., which does not include the option to split a data base into a front and back end. So, rather...
7
by: Peter Steele | last post by:
I have code to add a domain user to a local group but I'm not sure if it will work with NT domains or whether it will only work with Active Directory based systems. Here's the code: public void...
0
by: palomine1234 | last post by:
PAYPAL MAGIC!!! TURN $5 INTO $15,000 IN ONLY 30 DAYS...HERES HOW! This is a Money Scheme and Not, I repeat... This is Not a Scam!!!
48
by: meyer | last post by:
Hi everyone, which compiler will Python 2.5 on Windows (Intel) be built with? I notice that Python 2.4 apparently has been built with the VS2003 toolkit compiler, and I read a post from Scott...
1
by: Ryan Liu | last post by:
So for a UtpClient to JoinMulticastGroup, there must be a router in the network and with multicast enabled? That is, for a small LAN with a few computers connected by a hub or siwtch, it won't...
1
by: Brendan Miller | last post by:
I need a portable way to tell what subprocess.Popen will call. For instance on unix systems, Popen will work for files flagged with the executable bit, whereas on windows Popen will work on files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.