代码之家  ›  专栏  ›  技术社区  ›  Piers Karsenbarg

在datatextfield中组合两个字段。这有可能吗?

  •  29
  • Piers Karsenbarg  · 技术社区  · 14 年前

    我有一个要绑定到列表框的数据集。但是,我想组合两个字段来组成datatextfield。这是可能的,还是必须循环访问数据行?

    lstAddressDropdown.DataSource = dsAddress;
    lstAddressDropdown.DataTextField = "StreetAddress" + "Place";
    lstAddressDropdown.DataBind();
    lstAddressDropdown.Items.Insert(0, new ListItem("Please select"));
    

    值得注意的是,数据集是从Web服务返回的,因此我不能更改任何存储过程来组合其中的列。

    4 回复  |  直到 7 年前
        1
  •  43
  •   theChrisKent    14 年前

    docs: Multi-field Data Binding

    dsAddress.Tables[0].Columns.Add("StreetAndPlace",typeof(string),"StreetAddress + Place");
    lstAddressDropdown.DataSource = dsAddress;
    lstAddressDropdown.DataTextField = "StreetAndPlace";
    lstAddressDropdown.DataBind();
    lstAddressDropdown.Items.Insert(0, new ListItem("Please select"));
    

    "StreetAddress + ' ' + Place"

        2
  •  2
  •   LittleBobbyTables - Au Revoir    12 年前

    SELECT
    '<B>'||SHORTNAME||'</B><br/>('||DEPARTMENT||')' AS USERNAME
    FROM TABLE
    

    <b>Mr. Jagdeep Mankotia</b><br>
    (Web Application Development)
    
        3
  •  0
  •   mSrsF    7 年前

    DataSource.SelectCommand = "Select (Column1 || ' ' || Column2) As Column1And2 From Table";
    
    RadioButtonList1.DataTextField = "Column1And2";
    

        4
  •  -1
  •   fsteveb    11 年前