c# - ASP.NET Gridview: Highlighting rows on mouse over then updating the highlighted rows -


so have scoured internet solution problem, , haven't been successful far. trying update sql database based on "highlighted" rows in gridview in asp.net. here code have far highlighting.

// asp.net

// gridview1 row databound event: adds selection functionality protected void gridview1_rowdatabound(object sender, gridviewroweventargs e) {     e.row.attributes.add("onmousedown", "ismousedown(this)");     e.row.attributes.add("onmouseup", "ismousedown(this)");     e.row.attributes.add("onmouseover", "highlightrow(this)"); } 

// javascript

<script type="text/javascript">     var mousedown = false;      document.onselectstart = new function ("return false")      function ismousedown(row) {         if (mousedown == false) mousedown = true;         else mousedown = false          if (mousedown == true) {             highlightrow(row)         }     }      function highlightrow(row) {         if (mousedown == true) {             if (row.classname == 'gridhighlightedrow') {                 row.classname = 'gridnormalrow';             }             else {                 row.classname = 'gridhighlightedrow';             }         }     } </script> 

// css classes

.gridnormalrow {     background-color: #ffffff;  } .gridhighlightedrow {     background-color: #ffffcc; } 

the above code working perfectly, problem can't highlighted rows because javascript (based on understanding) modiefies tr tag, not actual gridview class or backcolor. have looked on place solution, need find identifier can access c# code update each row. have ideas?

quick edit

i thought of using type of hidden field, have no idea how javascript or need the row.attributes.add() make save hidden field. can see examples of need (javascript not strong suite)

use hiddenfield storing ids of highlighted rows/records. when highlightrow called, add selected id hiddenfield. after postback can read value in codebehind. or can use attributes on rows , store simple boolean selected. there many options how solve this.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -