GridView & setting parameters in code

L

Loading name...

Hey

asp.net 2.0

I have a GridView on my webpage. The datasource behind this GridView needs 1
parameter. This parameter is afaik only available from the code (the
parameter is the PortalModuleBase.UserId from DotNetNuke)...

I've set up 1 parameter for the sqldatasource and set its parameter source
to "none" in "command and parameter editor". and thought I should pass in
the correct value programmatically in a Page_Load event. Send the parameter
in as DataSourceSelectionArgument...

But I'm not sure my approach is the best here, maybe there is a better way
of doing this..

any suggestions
 
K

KJ

I'm sure there are many ways to do this. An approach I use a lot is to
add an asp:HiddenField control to the page. Then, when configuring the
datasource, I choose that hidden field to become a ControlParameter
(parameter source = control).

Then, at runtime, I set the Value property of the hidden field to the
value that the select method needs. Make sense?
 

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