Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Select a row in a Code generated table (not gridview)

Status
Not open for further replies.

Antithott

IS-IT--Management
Jan 20, 2006
90
0
0
DK
Hi all,

I tried searching both google and here before asking but i had no luck finding a suitable answer, so hoping someone could help me.

Im Querying a Mysql database for info, and then building a Table in the Code and once its been build, im sending it to a asp.net Table control.

All of this seems to work as it should.

My problem occurs when i want to select a row.
Im figuring i could put in a hyperlink in a empty cell in the end of the row, and click this to get the ID of Cell 1.
But i cant figure out how to accomplish this.

Illustaration:
________________________________
| ID | Name | Year | Hyperlink |

I want to click the Hyperlink and get a msgbox which contains the ID. the msgbox is just for testing purposes.

I hope someone can help me out
 
My answer .. Use a gridview... It will make what you are trying to do much easier..
 
Gridview was the first thing i tried, but i couldnt get all of it working, like showing diffrent pictures based on data from sql.

I would still appreciate it if anyone have any ideas as to how i can do this.
 
To show different pics based on data.. you would use the rowdatabound event of the gridview.
 
I figured out how to use rowdatabound in my gridview to insert pictures based on the data from Mysql query.

I stil cant figure out how to click a hyperlink and get the ID from cell1.

________________________________
| ID | Name | Year | Hyperlink |

I insert the Hyperlink by useing rowdatabound too.

 
I insert the Hyperlink by useing rowdatabound too.
You are adding the hyperlink dynamically? Why?
Enable selection on the gridview and use the SelectedIndexChanged event to get a reference to the selected row:
Code:
Dim gvRow As GridViewRow = GridView1.SelectedRow
Dim ID as Integer = gvRow.Cells(0).Text
Change .Cells(0) to the index of the column whos value you want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top