By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,030 Members | 1,227 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,030 IT Pros & Developers. It's quick & easy.

Javascript to perform validations based on datagrid's hidden column values

P: 40
Hi,

I am using c# asp.net application.I have datagrid which binds column dynamically and i make certain columns say visibility to false in my itemdatabound event EMPID AS E.ITEM.CELLS[3].VISIBLE = FALSE.Now i want to perform validations based on this value in cell[3] using javascript...

By clicking on one rows checkbox in datagrid, i need to color all other rows which has the same value in the hidden column EMP... IE cells[3]..

Expand|Select|Wrap|Line Numbers
  1. function colorSelectedRow(chkB)
  2.         {
  3.             var prefix = getCrtlPrefix();
  4.  
  5.             var dataGridCtrlName = prefix + 'dg_Approve';
  6.  
  7.             var hiddenTxtBoxName = prefix + 'hdnTxtRowOrgColor';
  8.  
  9.             //// Highlight the row of Matched Grid based on the Checkbox selection
  10.             var IsChecked = chkB.checked;
  11.  
  12.             var navRoot,node,dgRowid = null,tBody,rwVal;
  13.  
  14.             //// Get the RowID of the row checked by the user
  15.             var rowID = chkB.parentElement.parentElement.cells[1].innerText;
  16.             alert(rowID);
  17.             //// Get the GroupID of the row checked by the user
  18.             var reconseqNo = chkB.parentElement.parentElement.cells[3].innerText;            alert(reconseqNo);
  19.  
  20.             if(document.all && document.getElementById)
  21.             {
  22.                 navRoot = document.getElementById(dataGridCtrlName);
  23.                 if(navRoot != null)
  24.                 {
  25.                     tBody = navRoot.childNodes[0];
  26.                if(IsChecked)
  27.                 {             
  28.                     //// Loop through all the childnodes of the Form body to Highlight the Row checked by user and also its Matching Row
  29.                     for(i=1;i<tBody.childNodes.length;i++)
  30.                     {
  31.                         node = tBody.childNodes[i];
  32.  
  33.                         //node.style.backgroundColor = "Khaki";
  34.                          if(node.cells[1].innerText == rowID)
  35.                         {   
  36.                                      document.getElementById(node.childNodes[0].childNodes[0].id).checked = true;
  37.                                     if(document.getElementById(hiddenTxtBoxName).value == '')
  38.                                           node.style.backgroundColor = "Khaki";
  39.                         }
  40.  
  41.                         if(node.cells[3].innerText == rowID)
  42.                         {   
  43.                                      document.getElementById(node.childNodes[0].childNodes[0].id).checked = true;
  44.                                     if(document.getElementById(hiddenTxtBoxName).value == '')
  45.                                           node.style.backgroundColor = "Khaki";
  46.                         }
  47.                     }
  48.                     }

Reply asap
Dec 10 '09 #1
Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 8,639
and what exactly is not working? (what does the code do/not do?)
Dec 10 '09 #2

P: 40
When i click a checkbox in datagrid based on the reference column value of the row which is made visible false i need to automatically check the checbox of the matched rows and color it. It works fine if the reference column visibility is true. I want to perform the checking n coloring of matched rows based on the reference column which is made visible false at runtime
Dec 10 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.