Need to add TreeListCommandEventArgs in radbutton eventargs

108 views Asked by At
protected void RadButton1_Click(object sender, EventArgs e)
    {

        RadTreeList1.ItemCommand -= new EventHandler<TreeListCommandEventArgs>(RadTreeList1_ItemCommand);
        RadButton radbutton1 = (RadButton)Form.FindControl("RadButton1");
        TreeListDataItem dataItem = e.Item as TreeListDataItem;
        Hashtable table = new Hashtable();
        table["RowId"] = (dataItem.FindControl("Label1") as Label).Text;
        table["Alias"] = (dataItem.FindControl("Label2") as Label).Text;

    }


There I am getting error at Item as i dont have TreeListCommandEventArgs in radbutton pls help me in this
If I replace EventArgs with TreeListCommandEventArgs that doesnt meaningul and becomes error at runtime.....

2

There are 2 answers

0
Gopal Reddy On BEST ANSWER
protected void RadButton1_Click(object sender, EventArgs e)
{
    RadTreeList1.ItemCommand -= new EventHandler<TreeListCommandEventArgs>(RadTreeList1_ItemCommand);

    ContentPlaceHolder contentPage = this.Page.Master.FindControl("ContentPlaceHolder1") as ContentPlaceHolder;
    RadButton R = sender as RadButton;
    RadButton radbutton1 = R.Parent.FindControl("RadButton1") as RadButton;
    CommandEventArgs e2 = new CommandEventArgs(null, radbutton1.CommandArgument);
    TreeListCommandEventArgs e1 = new TreeListCommandEventArgs(null, radbutton1.CommandArgument, e2);
    TreeListDataItem dataItem = e1.Item as TreeListDataItem;
    Hashtable table = new Hashtable();
    table["RowId"] = (dataItem.FindControl("Label1") as Label).Text;
    table["Alias"] = (dataItem.FindControl("Label2") as Label).Text;
}
2
Gopal Reddy On
 protected void RadButton1_Click(object sender, EventArgs e)
        {


            ContentPlaceHolder contentPage = Page.Master.FindControl("ContentPlaceHolder2") as ContentPlaceHolder;
            RadButton radbutton1 = (RadButton)contentPage.FindControl("RadButton1");
            object mysender = (object)radbutton1;
            CommandEventArgs e2 = new CommandEventArgs(null, radbutton1.CommandArgument);
            RadButton1_Click(mysender, e2);
            TreeListCommandEventArgs e1 = new TreeListCommandEventArgs(null,radbutton1.CommandArgument,e2);
            TreeListDataItem dataItem = e1.Item as TreeListDataItem;
            Hashtable table = new Hashtable();
            table["RowId"] = (dataItem.FindControl("Label1") as Label).Text;
            table["Alias"] = (dataItem.FindControl("Label2") as Label).Text;

        }