LinqDataSource - Parameters

P

Philip

I am using the LINQDataSource.

I want to use a Parameter to for Select which is essentially a value within
a code variable. I have tried using inline code for the asp:parameter
DefaultValue, however this is not being driven.

Here is my existing code...

<asp:LinqDataSource ID="dataSource" runat="server"
ContextTypeName="SLCMS_DB_DataContext"
TableName="SLCMS_BannerAds"
Select="new(BannerAdKey, Enabled, ImageUrl, NavigateUrl,
AlternateText, Impressions, Width, Height, PublishDateTime)"
Where="Application=@Application && Group=@Group">
<WhereParameters>
<asp:SessionParameter Name="Application"
Type="String"
SessionField="_ConfigApplicationName" />
<asp:ControlParameter
Name="Group"
ControlID="RadTreeView1"
PropertyName="SelectedValue"
Type="String" />
</WhereParameters>
</asp:LinqDataSource>


Rather than have the SessionParameter I would like to use a asp:parameter
with a DefaultValue='<%= GetMyParameter() %>'.....however this will not
work....


Do you have any suggestions ? I essentially want to bring the Parameter in
from a code variable.
 
L

Lloyd Sheen

Philip said:
I am using the LINQDataSource.

I want to use a Parameter to for Select which is essentially a value within
a code variable. I have tried using inline code for the asp:parameter
DefaultValue, however this is not being driven.

Here is my existing code...

<asp:LinqDataSource ID="dataSource" runat="server"
ContextTypeName="SLCMS_DB_DataContext"
TableName="SLCMS_BannerAds"
Select="new(BannerAdKey, Enabled, ImageUrl, NavigateUrl,
AlternateText, Impressions, Width, Height, PublishDateTime)"
Where="Application=@Application && Group=@Group">
<WhereParameters>
<asp:SessionParameter Name="Application"
Type="String"
SessionField="_ConfigApplicationName" />
<asp:ControlParameter
Name="Group"
ControlID="RadTreeView1"
PropertyName="SelectedValue"
Type="String" />
</WhereParameters>
</asp:LinqDataSource>


Rather than have the SessionParameter I would like to use a asp:parameter
with a DefaultValue='<%= GetMyParameter() %>'.....however this will not
work....


Do you have any suggestions ? I essentially want to bring the Parameter in
from a code variable.

In code can you not capture the Selecting event and then ensure that the
parameter has the correct value?

LS
 
P

Philip

Sure....I could do that....but I was wanting to determine if there is a
simply way to access code variables from the asp:parameter ???

Any further thoughts ?
 
L

Lloyd Sheen

Philip said:
Sure....I could do that....but I was wanting to determine if there is a
simply way to access code variables from the asp:parameter ???

Any further thoughts ?
Sorry thats the best I got.
LS
 
P

Philip

So you are saying there is no way to use Inline Code within a SELECT set of
Parameters ?

Thanks for your prompt reply.
 
L

Lloyd Sheen

Philip said:
So you are saying there is no way to use Inline Code within a SELECT set of
Parameters ?

Thanks for your prompt reply.
Nope, what I was showing was the way I do it. I am sure there must be a
way but I have not used it. Sorry

LS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top