小弟日前写了个客户端的组件,目的是为了在不同的地方进行调用,但是不同的地方需要参数有不同,小弟不知道客户端控件是否可以带参数调用。控件代码很简单,如下:private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string sqlcommand = "select articleId,caption,publishTime from T_Article where ifHiding = '0' and articleType = '0101' and articleSubType = '0101' order by publishTime desc";
DBClass ds = new DBClass();
MyDataGrid.DataSource=ds.ReturnDataSet(sqlcommand,con);
MyDataGrid.DataBind();
MyDataGrid.Dispose();
}
就是说那个sql语句中的articleType和articleSubType后面带的参数需要调用控件的地方传入。请问怎么实现!先谢了

解决方案 »

  1.   

    后缀是ascx这个就是客户端的控件阿
      

  2.   

    现在程序改成这样的:但是还有错误private string articleType = "";
    private string articleSubType="";
    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面

    } public void BindDate()
    {
    try
    {
    SqlConnection con = DBClass.DBOpen();//读出数据连接
    string sqlcommand = "select articleId,caption,publishTime from T_Article where ifHiding = '0' and articleType = '"+articleType+"' and articleSubType = '"+articleSubType+"' order by publishTime desc";
    DBClass dbset=new DBClass();
    DataSet ds1=  dbset.ReturnDataSet(sqlcommand,con);
    MyDataGrid.DataSource=ds1;
    MyDataGrid.DataBind(); }
    catch(SqlException e)
    {
            throw new Exception(e.Message);
    } } public string SetArticleType
    {
    set
    {
    articleType = value;
    }
    } public string SetArticleSubType 
    {
    set
    {
    articleSubType = value;
    }
    }
    请高手指导