开发者

condition equal string

 <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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜