Solved

How to send GridViewRowEventArgs to OnCheckedChanged

Posted on 2006-06-29
15
788 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
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

816 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now