2014-12-30 51 views
1
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; 

    } 


有我在項目得到錯誤,因爲我不有radbutton TreeListCommandEventArgs請幫我在這
如果我TreeListCommandEventArgs這並不meaningul併成爲錯誤的替代EventArgs運行.....需要在radbutton EventArgs的添加TreeListCommandEventArgs

回答

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

     } 
+0

frrom在這裏,我可以能夠添加TreeListCommandEventArgs ....還是有一個例外...這是我不能能夠ŧ o找到RadTreeList內部的控制RadButton1 ..... –

+0

這裏可以找到RadButton1 –