Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically set parameters for EntityDataSource and DetailsView?

Im stumped!

What is the best way to programmatically set a selecting parameter for the EntityDataSource control?

Specifically, I want to use the Page.User.ProviderUserKey to get a record in a custom User Details table I have, for a DetailsView.

I've seen code using the asp:ControlParameter to pull a value from a control, but that almost seems like a hack for my situation. I don't want an extra control just to set the parameter value.

Any ideas? Thanks in advance!

like image 867
John B Avatar asked Nov 24 '25 22:11

John B


1 Answers

If creating a custom parameter type feels like too much work, you can programatically add a basic parameter as follows:

Parameter parameter = new Parameter("MyParam", TypeCode.String,
    Page.User.ProviderUserKey);
MyDataSource.SelectParameters.Add(parameter);

Something like this should give you what you need.

like image 165
Brandon Gano Avatar answered Nov 26 '25 11:11

Brandon Gano



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!