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.
精彩评论