Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to send GridViewRowEventArgs to OnCheckedChanged

Posted on 2006-06-29
15
Medium Priority
?
823 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:Hamed 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 400 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

916 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