troubleshooting Question

Access and Set Table Row ID

Avatar of codequest
codequest asked on
JavaScript
5 Comments1 Solution304 ViewsLast Modified:
I'm using the following as a test to learn about some functionality I might want to use.
It involves getting and setting the Id of a table row.  
I'm clearly not doing it right...is there a way to do it, and if so, how?

function Button2_onclick() {
var wrkRow=document.getElementById("Row2")
alert(wrkRow.tagName)   //  <=== This works, shows "TR"
alert(wrkRow.Id)            //  <=== This fails, shows undefined
wrkRow.Id="Hey"
wrk2Row = document.getElementById("Hey")   // <== blows up here, can't find an object with Id="Hey"
alert(wrk2Row.Id)  
}

Actually, what I want to do is run a javascript function that will assign unique ID's to all the rows in a table (in this instance a rendered ASP.NET Gridview).   So this was just one approach that I thought I might be able to use...get the row as an object, and set its Id Property...(updating an existing Id would just be gravy)...but, these are all just newbie assumptions, so...

Any help on this would be appreciated.

Thanks!
ASKER CERTIFIED SOLUTION
timker

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros