编程道

My Links

Blog Stats

News

WebCombo 添加自定义下拉列表

    不太会用NetAdvantage这个控件,昨天折腾了半天。本来以为会像Asp.net里的DropDownList一样,结果发现在属性里添加Columns,再在Rows里添加没效果,后来查到网上有人将Hashtable与DropwDownList绑定,在WebCombo上也不行,只好用内存表方式,照着例子将DataSource和DataMember设置为内存表的DataSet和表名,还是不行,真是奇怪啊,后来看到UltraWebGrid里将DataSource直接绑定到表,试着在WebCombo上用了一下,可以了。

protected Infragistics.WebUI.WebCombo.WebCombo ConditionCB;

        
private void SetConditionCB()
        
{
            DataSet dsCondition
=new DataSet("dsCondition");
            DataTable tData
=new DataTable("tData");

            DataColumn cName
=new DataColumn("条件");
            tData.Columns.Add(cName);

            DataRow RowData;
            RowData
=tData.NewRow();
            RowData[
"条件"]="等于";
            tData.Rows.Add(RowData);

            RowData
=tData.NewRow();
            RowData[
"条件"]="包含";
            tData.Rows.Add(RowData);

            RowData
=tData.NewRow();
            RowData[
"条件"]="匹配开头";
            tData.Rows.Add(RowData);

            RowData
=tData.NewRow();
            RowData[
"条件"]="不等于";
            tData.Rows.Add(RowData);

            RowData
=tData.NewRow();
            RowData[
"条件"]="大于";
            tData.Rows.Add(RowData);

            RowData
=tData.NewRow();
            RowData[
"条件"]="大于或等于";
            tData.Rows.Add(RowData);

            RowData
=tData.NewRow();
            RowData[
"条件"]="小于";
            tData.Rows.Add(RowData);

            RowData
=tData.NewRow();
            RowData[
"条件"]="小于或等于";
            tData.Rows.Add(RowData);
            
            dsCondition.Tables.Add(tData);
            
            
//ConditionCB.DataSource=dsCondition;
            ConditionCB.DataSource=dsCondition.Tables[0];
            
//ConditionCB.DataMember="tData";
            ConditionCB.DataBind();
            

            
/*
            Hashtable condition=new Hashtable();
            condition.Add("等于","等于");
            condition.Add("包含","包含");
            condition.Add("不包含","不包含");
            condition.Add("匹配开头","匹配开头");
            condition.Add("不匹配开头","不匹配开头");
            condition.Add("匹配结尾","匹配结尾");
            condition.Add("不匹配结尾","不匹配结尾");
            condition.Add("不等于","不等于");
            condition.Add("大于","大于");
            condition.Add("大于或等于","大于或等于");
            condition.Add("小于","小于");
            condition.Add("小于或等于","小于或等于");
            condition.Add("空","空");
            condition.Add("非空","非空");
            
            //ConditionCB.Columns.Add("","查询条件");
            ConditionCB.DataSource=condition;
            //ConditionCB.DataMember="";
            ConditionCB.DataValueField="Key";
            ConditionCB.DataTextField="Value";
            ConditionCB.DataBind();
            
*/

        }

posted on 2005-11-24 15:52 编程道 阅读(...) 评论(...) 编辑 收藏