Click here to Skip to main content
15,917,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Recently i have created a functionality where checking the master check box in grid view all the check boxes get checked which is working fine. However there is a problem that on the selected rows of check boxes in grid view i have different cells whose data i wanna access on a click of button.
For that I am making use of loops but i am not able to do so as every time i reach the loop it takes me to the javascript which I am using for check box functionality.
Can anyone please point out my mistake ???
JavaScript
function HeaderClick(CheckBox)
{
   //Get target base & child control.
   var TargetBaseControl = 
       document.getElementById('<%= this.gvAllClients.ClientID %>');
   var TargetChildControl = "chkEmail_Single";

   //Get all the control of the type INPUT in the base control.
   var Inputs = TargetBaseControl.getElementsByTagName("input");

   //Checked/Unchecked all the checkBoxes in side the GridView.
   for(var n = 0; n < Inputs.length; ++n)
      if(Inputs[n].type == 'checkbox' && 
                Inputs[n].id.indexOf(TargetChildControl,0) >= 0)
         Inputs[n].checked = CheckBox.checked;

   //Reset Counter
   Counter = CheckBox.checked ? TotalChkBx : 0;
}



and this is my coding for the loop:
C#
protected void btnEmail_Click(object sender, EventArgs e)
   {

       for (int ict = 0; ict < gvAllClients.Rows.Count; ict++)
       {
           CheckBox check = ((CheckBox)(gvAllClients.Rows[ict].FindControl("chkEmail_Single")));
           if (check.Checked = true)
           {
               string strDatatype = gvAllClients.Rows[ict].Cells[5].Text.ToString();
           }
       }
       }
Posted
Comments
Taresh Uppal 16-May-12 5:15am    
I will be waiting for any suggestion...Thanx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900