在 ImageButton 控件中传递多个命令参数?
我正在设计一种分层系统,如下:
Contract
大师商品
商品
子商品
部分
其中每一个都在自己的页面上(目前)。用户从 Contract.aspx 页面开始。如果他们想查看当前合约的主商品,他们将单击我设置的“ImageButton”,然后我将 ContractID 作为命令参数传递(CommandArgument='<%# Eval (“ContractID”)%>'
)。这非常有效 - 我进入了我的主商品页面,其中的主商品根据我传入的 ContractID 进行了过滤。
这是我的问题:从主商品页面导航到商品页面将(我认为)需要传入 ContractID(所以我们只需查看我们正在签订的合约的内容)以及主商品 ID(因此我们只需查看与主商品相关的商品)。我已尝试以下操作:
CommandArgument='<%# Eval("ContractID") + ',' + Eval("MComID")%>'
,但正如您可能期望的那样,那是行不通的。如果我可以做类似上面的事情并有一个像逗号这样的分隔符,我就可以从那里开始并使其工作。有什么建议吗???
I'm designing a sort of hierarchical system, as follows:
Contract
Master Commodity
Commodity
Sub-Commodity
Part
Each one of these are on their own page (for now). The user starts out on the Contract.aspx page. If they want to see the Master Commodities for the contract they are currently on, they will click the "ImageButton" I have set up, and I pass in as a command argument the ContractID (CommandArgument='<%# Eval("ContractID")%>'
). This works great- I get to my Master Commodity page with the Master Commodities filtered on the ContractID I passed in.
Here's my problem: Navigating from the Master Commodity page to the Commodity page will (I think) require passing in the ContractID (so we JUST see stuff for the contract we're on), AND the Master Commodity ID (so we JUST see the Commodities that are related to the Master Commodity). I've tried the following:
CommandArgument='<%# Eval("ContractID") + ',' + Eval("MComID")%>'
, but as you could probably expect, that doesn't work. If I can just do something like above and have a delimiter like the comma, I can go from there and make it work. Any suggestions???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
迈克,
借用您自己建议的解决方案,您可以保留 ImageButton 并使用以下内容:
在当天晚些时候,但认为值得为关注此线程的其他人发表评论。
保罗.
Mike,
borrowing form your own suggested solution you could have kept your ImageButton and used the following:
Late in the day but thought worth commenting for others following this thread.
Paul.
我决定做的是将我的 ImageButton 更改为“a href...”并将其用作我的 href:
这样我就可以传递我需要的所有信息。
What I decided to do is change my ImageButton to an "a href..." and use this as my href:
That way I can pass in all the information I need.
建议在后面的代码中添加一个方法,该方法返回一个格式良好的字符串,
然后您可以在控件中
Eval
此函数。这样,您就可以保留代码中的格式化逻辑,并且只需在那里进行修改即可。如果信息用于前端代码的不同控件(链接),这是一个很好的做法。A suggestion is having a method in your code behind, which returns a well-formatted string
you could then
Eval
this function in your control. this way you keep the logic of formatting in your code behind, and only have to modify it there. This is a good practice if the information is used in different controls ( links ) on your front-end code.