如何以编程方式设置EntityDataSource和DetailsView参数? [英] How to programmatically set parameters for EntityDataSource and DetailsView?

查看:123
本文介绍了如何以编程方式设置EntityDataSource和DetailsView参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林难倒!

什么是编程设置为 EntityDataSource 控制选择参数的最佳方式?

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

具体来说,我想用Page.User.ProviderUserKey获得创纪录的自定义用户详细信息表我有,一个DetailsView。

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

我见过使用 ASP code:ControlParameter 来从控制拉一个值,但似乎像我的情况一劈。我不希望有一个额外的控制只是设置的参数值。

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!

推荐答案

如果创建一个自定义的参数类型感觉太辛苦了,你可以编程添加一个基本参数如下:

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.

这篇关于如何以编程方式设置EntityDataSource和DetailsView参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆