Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m using checkboxs in grid view with that on the selected check box i want to perform comparision with an some entry in the database and i want to retrieve that data on the button click
Posted

Hi,

try this way to do that
After comparission the resulted data to de save in session variable .

And use that session variable in button click event.


All the Best
 
Share this answer
 
you can check these link ^^^

Hope be helpful,
Theingi Win
 
Share this answer
 
C#
if (GridvView1.Rows.Count > 0)
{
	GridViewRowCollection rc = GridvView1.Rows;
	foreach (GridViewRow gRow in rc)
	{
		CheckBox cBox = (CheckBox)(gRow.FindControl("chkSelect"));

		if (cBox.Checked == true)
		{
			//comparisions to be made &
			//if u want to save any values then use some or 
			//static variables    
		}
	}
}
 
Share this answer
 
v2
Hi Sanjay

If this solution is useful for you then please vote.
In this code you have to write manually Checked Changed event.

Example-----
C#
 <asp:Templatefield headertext="Check" >
         <itemtemplate> 
<asp:checkbox id="Chk1" runat="server" autopostback="True"
                  oncheckedchanged="chk1_CheckedChanged" />                  
         </itemtemplate> 

In this code you have to write manually "oncheckedchanged="chk1_CheckedChanged" you have to change only your check box name here is check box name is "chk1"
Now the below is the code behind the event.
C#
 protected void chk1_CheckedChanged(object sender, EventArgs e)
    {
        GridViewRow selectedRow = (GridViewRow)((CheckBox)sender).NamingContainer;
        int RowIndex = selectedRow.RowIndex;
Label lbl_A = (Label)GridView1.Rows[RowIndex].FindControl("lbl_A");
}

In this back end code you can find control and perform any operation on the check box checked event.

If you have any doubt please ask.
 
Share this answer
 
v4

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