Solved

How to send GridViewRowEventArgs to OnCheckedChanged

Posted on 2006-06-29
15
815 Views
Last Modified: 2010-05-18
How to send GridViewRowEventArgs to OnCheckedChanged? It's not possible to just replace EventArgs with GridViewRowEventArgs.

    protected void Velg_CheckedChanged(object sender, EventArgs e)
    {
        Label2.Text = "asdasdasd";
    }
0
Comment
Question by:m-jansen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
15 Comments
 
LVL 9

Expert Comment

by:zaghaghi
ID: 17009260
It's not possible to replace these types
0
 

Author Comment

by:m-jansen
ID: 17009309
how to deal with it?
0
 
LVL 10

Expert Comment

by:aki4u
ID: 17012418
what are you trying to do?
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:m-jansen
ID: 17012469
>what are you trying to do?
when a checkbox is clicked another c# method should be run
0
 

Author Comment

by:m-jansen
ID: 17012483
I have actuallt almost figured out how to deal with it like this.

   protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            CheckBox Velg = (CheckBox)e.Row.FindControl("Velg");
            Velg.Attributes.Add("onclick", ""+ list.Add(32) +"");
        }
    }

but the value 32 does not add to my list when I click the select button
0
 

Author Comment

by:m-jansen
ID: 17012495
ops I mean the checkbox
0
 
LVL 10

Expert Comment

by:aki4u
ID: 17012739
list.Add(32) is a codebehind(server side) what will not work with "onclick" event (client side).
0
 

Author Comment

by:m-jansen
ID: 17012773
If I can't use onclick and not use OnCheckedChanged. What to do then? There have to be a someway to handle this?
0
 
LVL 10

Expert Comment

by:aki4u
ID: 17012853
you could use OnCheckedChanged, I don't see why not.                                      
0
 

Author Comment

by:m-jansen
ID: 17012907
Good. How would you suggest to it?
0
 

Author Comment

by:m-jansen
ID: 17016315
I need to send a GridViewRowEventArgs to the OnCheckedChanged method. How to do it? It sounds difficult to me.
0
 
LVL 10

Expert Comment

by:orbulat
ID: 17016431
..
CheckBox Velg = (CheckBox)e.Row.FindControl("Velg");
Velg.CheckedChanged +=new EventHandler(Velg_CheckedChanged);

....

private void Velg_CheckedChanged(object sender, EventArgs e)
{
    ...
    //do your stuff
    ..
}
0
 

Author Comment

by:m-jansen
ID: 17016475
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
CheckBox Velg = (CheckBox)e.Row.FindControl("Velg");
Velg.CheckedChanged += new EventHandler(Velg_CheckedChanged);
}

protected void Velg_CheckedChanged(object sender, EventArgs e) {
string s = e.Row.Cells[0].Text;
}


This code does not work.
0
 
LVL 10

Accepted Solution

by:
aki4u earned 100 total points
ID: 17017794
"I need to send a GridViewRowEventArgs to the OnCheckedChanged method. How to do it? It sounds difficult to me."
-you can't do this

To respond to a checkbox CheckedChanged event in DataGrid, you need to specify in html code of the CheckBox: OnCheckedChanged="Velg_CheckedChanged" and AutoPostBack="True".
Now, if you want to get some information about the cell where checkbox is copy this code:

protected void Velg_CheckedChanged(object sender, EventArgs e)
{
      CheckBox chk = (CheckBox)sender;
      TableCell cell= (TableCell)chk.NamingContainer.Controls[1];//assuming your checkbox is first column in DataGrid
      string cellText = cell.Text;
}
0
 

Author Comment

by:m-jansen
ID: 17018902
Thanks for good help
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question