zoukankan      html  css  js  c++  java
  • Coolite ComboBox数据绑定

    aspx代码:
    1     <div>
    2 <ext:Store ID="Store1" runat="server" AutoLoad="true">
    3 <Reader>
    4 <ext:jsonreader readerid="employee_no">
    5 <%--<ext:ArrayReader>--%>
    6 <Fields>
    7 <ext:RecordField Name="employee_no">
    8 </ext:RecordField>
    9 <ext:RecordField Name="employee_display_name">
    10 </ext:RecordField>
    11 </Fields>
    12 <%--</ext:ArrayReader>--%>
    13 </ext:JsonReader>
    14 </Reader>
    15 </ext:Store>
    16 <ext:ComboBox ID="ComboBox1" runat="server" StoreID="Store1" Width="250" Editable="false"
    17 TypeAhead="true" Mode="Local" ForceSelection="true" TriggerAction="All" SelectOnFocus="true"
    18 EmptyText="Please choose..." >
    19 </ext:ComboBox>
    20 </div>
    21 <ext:ScriptManager ID="ScriptManager1" runat="server">
    22 </ext:ScriptManager>

     CS代码:

    1 foreach (DataRow r in ds.Tables[0].Rows)
    2 {
    3 ComboBox1.Items.Add(new Coolite.Ext.Web.ListItem(r[1].ToString(), r[0].ToString()));
    4 }

    用这种方式时,页面使用jsonreaderArrayReader均可;

    或者以下方式绑定:

    cs代码:
    1       Store1.DataSource = ds.Tables[0];
    2 Store1.DataBind();
    3 ComboBox1.ValueField = "employee_no";
    4 ComboBox1.DisplayField = "employee_display_name";
    5 //ComboBox1.StoreID = Store1.ClientID;
    6   ComboBox1.DataBind();

     用这种方式时,页面使用jsonreader;StoreID 如果页面指定,则此处可不加ComboBox1.StoreID = Store1.ClientID;

  • 相关阅读:
    最全的机器学习资源整理
    论文写作技巧
    制造业期刊-ZT
    机器学习中的算法(2)-支持向量机(SVM)基础
    定语从句
    Digital Twin的8种解读!
    详解BOM用途分类及在汽车企业中的应用
    Intellij IDEA运行报Command line is too long解法
    计算机行业各种职业技能树
    invocationCount和invocationTimeOut
  • 原文地址:https://www.cnblogs.com/pfs1314/p/1729944.html
Copyright © 2011-2022 走看看