复制代码 代码如下:
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});
}
新闻热点
疑难解答
图片精选