Link to home
Start Free TrialLog in
Avatar of m-jansen
m-jansen

asked on

How to send GridViewRowEventArgs to OnCheckedChanged

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";
    }
Avatar of Hamed Zaghaghi
Hamed Zaghaghi
Flag of Iran, Islamic Republic of image

It's not possible to replace these types
Avatar of m-jansen
m-jansen

ASKER

how to deal with it?
what are you trying to do?
>what are you trying to do?
when a checkbox is clicked another c# method should be run
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
ops I mean the checkbox
list.Add(32) is a codebehind(server side) what will not work with "onclick" event (client side).
If I can't use onclick and not use OnCheckedChanged. What to do then? There have to be a someway to handle this?
you could use OnCheckedChanged, I don't see why not.                                      
Good. How would you suggest to it?
I need to send a GridViewRowEventArgs to the OnCheckedChanged method. How to do it? It sounds difficult to me.
..
CheckBox Velg = (CheckBox)e.Row.FindControl("Velg");
Velg.CheckedChanged +=new EventHandler(Velg_CheckedChanged);

....

private void Velg_CheckedChanged(object sender, EventArgs e)
{
    ...
    //do your stuff
    ..
}
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.
ASKER CERTIFIED SOLUTION
Avatar of aki4u
aki4u

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for good help