none
sqldatasource数据源使用了“;”号,就取不到Control值了? RRS feed

  • 问题

  •     sqldatesource 的代码见代码1,用它来做某个DropDownList的数据源,其Control值只能显示ContractNumber,不能显示其他的City,Road ,Address值。    该如何解决呢?非得用两个Sqldatasource么?

    select ContractNumber 
    from ContractTable 
    ;
    select City,Road ,Address 
    from ContractTable 
    where CID>100


    C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!

    2014年4月14日 2:25

答案

  • 为什么你不使用FilterExpression 表达式,

    <asp:SqlDataSource 
        ID="SqlDataSource1" 
        DataSourceMode="DataSet"
        EnableCaching="true"
        Runat="server" 
        SelectCommand="select ContractNumber,City,Road ,Address from ContractTable "
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        FilterExpression="CID> 100">
    </asp:SqlDataSource>
    

    参考这个链接:

    Enable Filtering for the SqlDataSource Control

    http://msdn.microsoft.com/en-us/library/59bfya48(v=vs.100).aspx


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年4月16日 9:27
    版主

全部回复

  • 为什么要写2条,写一起不行吗?

      select ContractNumber,City,Road ,Address

    from ContractTable

    http://feiyun0112.cnblogs.com/

    2014年4月14日 6:35
    版主
  •     有些加了where 条件啊!

    C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!

    2014年4月14日 7:06
  • 为什么你不使用FilterExpression 表达式,

    <asp:SqlDataSource 
        ID="SqlDataSource1" 
        DataSourceMode="DataSet"
        EnableCaching="true"
        Runat="server" 
        SelectCommand="select ContractNumber,City,Road ,Address from ContractTable "
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        FilterExpression="CID> 100">
    </asp:SqlDataSource>
    

    参考这个链接:

    Enable Filtering for the SqlDataSource Control

    http://msdn.microsoft.com/en-us/library/59bfya48(v=vs.100).aspx


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年4月16日 9:27
    版主