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;

  • 相关阅读:
    go 代理
    mongo创建用户
    博客搬家&留言板
    noip2020 SD选手迷惑行为大赏
    noip2020游记
    P4174 [NOI2006] 最大获利
    P3327 [SDOI2015]约数个数和
    P5069 [Ynoi2015]纵使日薄西山
    P3747 相逢是问候
    HDE6315 Naive Operations
  • 原文地址:https://www.cnblogs.com/pfs1314/p/1729944.html
Copyright © 2011-2022 走看看