需要在radbutton eventargs中添加TreeListCommandEventArgs

时间:2014-12-30 09:31:58

标签: c# telerik radtreelist

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;

    }


我在Item收到错误,因为我在radbutton中没有TreeListCommandEventArgs请帮助我
如果我将EventArgs替换为TreeListCommandEventArgs并且没有意义并且在运行时变为错误.....

2 个答案:

答案 0 :(得分:1)

 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;

        }

答案 1 :(得分:1)

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;
}