0

I have a gridview with checkboxes. Am binding data to gridview in pageload. Upon selection of checkbox i am changing gridview row color by finding gridview row id (code written in javascript).

document.getElementById(gv_ctrl02).style.backgroundColor = "beige";    

and gridview data rendering as below row ids.

table
tr id="gv_ctrl02" td 1000 /td td Anil /td  /tr
tr id="gv_ctrl02" td 1002 /td td Suri /td  /tr
tr id="gv_ctrl02" td 1003 /td td Jagan /td  /tr   
table  

I have a button on my page and on click of it some action is happening. after that i check gridview rendred code it is not having row ids and below is my gridview rendered code

table
tr  td 1000 /td td Anil /td  /tr
tr  td 1001 /td td Suri /td  /tr
tr  td 1003 /td td Jagan /td  /tr   
table  

As the rowids not generated, code for changing row color is not working.

document.getElementById(gv_ctrl02).style.backgroundColor = "beige";
//throwing Null javascript exception due to row id gv_ctrl02 is not available.
Andrei
  • 55,890
  • 9
  • 87
  • 108
user1463065
  • 563
  • 2
  • 11
  • 30
  • Can you clean up your question to format your code using Markdown. It's very hard to read this. – Philip Pittle Dec 03 '14 at 12:38
  • And this sounds very similar to: http://stackoverflow.com/questions/27187778/unique-variable-names/27189964#27189964 – Philip Pittle Dec 03 '14 at 12:39
  • Can you post your GridView markup on the server side? ASP.NET always generates ids for server side controls, so your problem looks really strange. That said, using generated ids in javscript is not the best of ideas, have you considered other ways? – Andrei Dec 03 '14 at 12:45

0 Answers0