復制代碼 代碼如下:
public void BindSearchDataToGridView(string ddlvalue,string txtValue)
{
//ddlvalue 為用戶控件中dropdownlist控件的值
//txtValue 為用戶控件中textbox控件的值
//通過傳進來的參數去查詢數據,然后綁定到gridview控件上
//在這里寫上綁定數據的方法
}
復制代碼 代碼如下:
protected void btnSearch_Click(object sender, EventArgs e)
{
System.Web.UI.Page motherPage = this.Page;
Type pageType = motherPage.GetType();
//這里用到了反射
System.Reflection.MethodInfo mi = pageType.GetMethod("BindSearchDataToGridView"); //"BindSearchDataToGridView"為.aspx頁面文件的方法
string txtValue= TextBox1.Text;
string ddlvalue= DropDownList1.SelectedValue.ToString();
mi.Invoke(motherPage, new object[] { ddlvalue, txtValue});
}
新聞熱點
疑難解答
圖片精選