开发者

condition equal string

开发者 https://www.devze.com 2023-03-28 13:19 出处:网络
<asp:LinqDataSource ID=\"LinqDataSource2\" runat=\"server\" ContextTypeName=\"DataClassesDataContext\"
 <asp:LinqDataSource ID="LinqDataSource2" runat="server" ContextTypeName="DataClassesDataContext"
                       TableName="PrivateMessages" Where="Sender == @Sender">
    <WhereParameters>
        <asp:QueryStringParameter Name="Sende开发者_StackOverflow社区r"  QueryStringField="idCompany" Type="String" />
    </WhereParameters>
</asp:LinqDataSource>:LinqDataSource>

this code select from table PrivateMessages where Sender==QueryString('idCompany') this code work fine.

i want select from privateMessage where Sender=="admin"????????

where sender equal a const string.


You can use Selecting event and do like..

protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    e.WhereParameters["Sender"] = set here...
}


Or you can replace the WhereParameters section with something like

 <WhereParameters>
    <asp:Parameter Name="Sender" Type="String" DefaultValue="admin" />
 </WhereParameters>

Depends on you in choosing what flavor of this 2 solutions best suits this scenario.

0

精彩评论

暂无评论...
验证码 换一张
取 消