473,387 Members | 1,925 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,387 software developers and data experts.

How to get a ID into a tablerow of a datagrid

Not sure if the subject covers the story to well, but I hope someone
can help me with this little problem. I have a div that turns switches
to visible and invisible when going over a row in a datagrid. I shows
some information about the hightlighted product. For every row there
is a div generated with it's own id.

Now the problem is, when you want to put an onmouseout event in a
table row, you have to do it something like this:
Private Sub viewGrid_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
viewGrid.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseout", "hide(this, ds" &
prodId & ")")
End If
End Sub

But I can't seem to get the ID filled with the id I retrieve from
tablerow where I fill datagrid with.

Does anyone have an idea of how to do this?

Thanks,

Ricky

Apr 11 '07 #1
6 1420
If you need the id that the row will have on client side, you can get it as
e.Item.ClientID. Or you mean something else?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
<rw********@gmail.comwrote in message
news:11*********************@d57g2000hsg.googlegro ups.com...
Not sure if the subject covers the story to well, but I hope someone
can help me with this little problem. I have a div that turns switches
to visible and invisible when going over a row in a datagrid. I shows
some information about the hightlighted product. For every row there
is a div generated with it's own id.

Now the problem is, when you want to put an onmouseout event in a
table row, you have to do it something like this:
Private Sub viewGrid_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
viewGrid.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseout", "hide(this, ds" &
prodId & ")")
End If
End Sub

But I can't seem to get the ID filled with the id I retrieve from
tablerow where I fill datagrid with.

Does anyone have an idea of how to do this?

Thanks,

Ricky

Apr 11 '07 #2
On 11 Apr, 15:01, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
If you need the id that the row will have on client side, you can get it as
e.Item.ClientID. Or you mean something else?
Thanks for your quick reply, but indeed, I mean something else. What I
need is the prodId that I select from a table.

"SELECT producten.id as <b>prodId</b>, producten.omschrijving1 as
prodOmschr1, producten.omschrijving2 as prodOmschr2, prodSoort.naam as
prodSoort, producten.jaar as prodJaar, producten.foto as prodFoto,
prodStreken.naam as prodStreek, prodLanden.naam as prodLand,
producten.prijs as prodPrijs " & _
" FROM producten, prodSoort, prodStreken, prodLanden " & _
" WHERE producten.soort = prodSoort.id and producten.streek =
prodStreken.id and producten.land = prodLanden.id"
Dim objConnection As New
OdbcConnection(ConfigurationManager.AppSettings("c onnString"))
Dim objAdapter As New OdbcDataAdapter(strMySQL, objConnection)
Dim objDataSet As New DataSet()

With this query I fill the datagrid. On each row of the datagrid I
have a mouseover atribute. This mouseover should be accompanied with
the orderId.

Hope I'm clearer now. :)

Thnx

Apr 11 '07 #3
e.Item.DataItem gives you a reference on the item in the datasource that
gets bound to the current grid row. You need to typecast it to the type of
your datasource and from there you can get to the fields. prodId will be in
the first field.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
<rw********@gmail.comwrote in message
news:11**********************@d57g2000hsg.googlegr oups.com...
On 11 Apr, 15:01, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
>If you need the id that the row will have on client side, you can get it
as
e.Item.ClientID. Or you mean something else?

Thanks for your quick reply, but indeed, I mean something else. What I
need is the prodId that I select from a table.

"SELECT producten.id as <b>prodId</b>, producten.omschrijving1 as
prodOmschr1, producten.omschrijving2 as prodOmschr2, prodSoort.naam as
prodSoort, producten.jaar as prodJaar, producten.foto as prodFoto,
prodStreken.naam as prodStreek, prodLanden.naam as prodLand,
producten.prijs as prodPrijs " & _
" FROM producten, prodSoort, prodStreken, prodLanden " & _
" WHERE producten.soort = prodSoort.id and producten.streek =
prodStreken.id and producten.land = prodLanden.id"
Dim objConnection As New
OdbcConnection(ConfigurationManager.AppSettings("c onnString"))
Dim objAdapter As New OdbcDataAdapter(strMySQL, objConnection)
Dim objDataSet As New DataSet()

With this query I fill the datagrid. On each row of the datagrid I
have a mouseover atribute. This mouseover should be accompanied with
the orderId.

Hope I'm clearer now. :)

Thnx

Apr 11 '07 #4
On 11 Apr, 16:09, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
e.Item.DataItem gives you a reference on the item in the datasource that
gets bound to the current grid row. You need to typecast it to the type of
your datasource and from there you can get to the fields. prodId will be in
the first field.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
I'm sorry, I don't think I understand you completely. What do you mean
with "typecast it to the type of your datasource"?

Thanks.

Apr 11 '07 #5
If you know that you databind the grid to a datatable, you know that the
type of DataItem will be DataRowView.

Look up the MSDN on DataItem. It has an example.
http://msdn2.microsoft.com/en-us/lib...em(vs.71).aspx

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
<rw********@gmail.comwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
On 11 Apr, 16:09, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
>e.Item.DataItem gives you a reference on the item in the datasource that
gets bound to the current grid row. You need to typecast it to the type
of
your datasource and from there you can get to the fields. prodId will be
in
the first field.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

I'm sorry, I don't think I understand you completely. What do you mean
with "typecast it to the type of your datasource"?

Thanks.

Apr 11 '07 #6
It works now :)
Thank you verry much!

Apr 11 '07 #7

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

Similar topics

2
by: thomasamillergoogle | last post by:
Hi, As you can see from the code below I have a simple js function called getFormElementsinTableRow(rowName). rowName is the ID of the tableRow. I just want to use js to find the child ID's of all...
3
by: Rajeev | last post by:
Hi I can use the TableRow and TableCell class in C# while using Web forms. The same are not available while programming with Windows Forms. I have the folloowing code that works fine with Web...
0
by: Randy | last post by:
Hello All, Is there any way to make this happen... Say I want to make a table with 3 rows. The first row has two TableCells each with a width of 300. The second row has one TableCell with the...
3
by: Steve - DND | last post by:
Is there any way to create a click event for a TableRow? It doesn't seem to be built in by default. If anyone knows how this can be implemented it would be most appreciated. Thanks, Steve
2
by: George Durzi | last post by:
Consider this pseudo HTML from a web form <asp:Table> <asp:TableRow> <asp:TableCell> <asp:Table> <asp:TableRow> <asp:TableCell></asp:TableCell> <asp:TableCell></asp:TableCell>...
3
by: RobertH | last post by:
Hello all. I have been hacking away trying to get a SQL image (jpeg) to render in a control or table row Without using the Response.BinaryWrite.... I think i might be on the verge but need a...
6
by: hb | last post by:
Hi, I have a page bill.aspx and its code-behind bill.aspx.cs. On bill.aspx I have: === Select a month: <asp:dropdownlist runat="server" id="lstDate" autopostback="True" /> <br> <asp:table...
3
by: Alex Maghen | last post by:
Okay, I'm sure that this is an incredibly simple one and it may have more to do with HTML than with ASP.NET I have an ASP:Table with no borders and that table has several ASP:TableRows, each with...
1
by: Harry | last post by:
Dear All, I would like to know whether it is possible to add a table in tablerow? Dim Table1 As New Table. Dim Row1 As New TableRow Dim Table2 As New Table Row1.Cells.Add(Table2) ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.