GridView & setting parameters in code

  • Thread starter Thread starter Loading name...
  • Start date Start date
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
 
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?
 
Back
Top