首页 新闻 会员 周边

枚举控件问题

0
悬赏园豆:10 [已关闭问题] 关闭于 2008-11-13 09:56

小弟想在一个函数中对DataGrid,DataView进行数据绑定,但是感觉没法通过枚举参数实现。

思路如下:

protected enum ControlType
    {
       DataView,
       DataGrid
    }

 internal void Query(ControlType control, string sql) {
       
        DataSet ds; string message;
        ds = DB.ExecSql(。。。);       
        this.gv1.DataSource = ds.Tables[0];
        this.gv1.DataBind();
    }

但是感觉没法通过判断control来判断控件是DataView或者DataGrid来绑定,请指教。

Shapley的主页 Shapley | 初学一级 | 园豆:55
提问于:2008-11-05 10:19
< >
分享
所有回答(1)
0

Control Ctl;

if (ctl is DataSet )

{...}

if (ctl is DataView)

{...}

| 园豆:770 (小虾三级) | 2008-11-05 10:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册