包含 LinkButton 的 ASP .NET Repeater 控件
我正在中继器中显示帐户对象列表。每个对象包含三个字段,即studentID、studentName 和studentAge。我用 链接按钮。因此,显示的每个单独项目都是可单击的。我还向链接按钮添加了一个单击处理程序。问题是我如何知道哪个学生被点击了?因为最初我想导航到下一页并显示该特定学生的详细信息。一旦我知道点击了哪个学生,我就可以将他的详细信息存储在会话对象中,然后导航到新页面并将其取回。
感谢您的帮助。
I am displaying a list of accounts objects in a repeater. Each object contains three fields namely studentID, studentName and studentAge. I have wrapped it with a link button. As a result the each individual item which is displayed is clickable. I have also added a click handler to the link button. The problem is that how am I supposed to know which student was clicked? Because originally I want to navigate to the next page and display that particular student's details. Once I know which student is clicked then I can store his details in a session object and then navigate to the new page and get it back.
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的情况下,最好使用普通的超链接,将 ID 作为查询字符串传递,然后让新页面获取详细信息。
更新:
要在同一页面上获取学生ID,请使用ItemCommand 事件代替,并具有
LinkButton
,如下所示:studentID 将存储到
CommandArgument
属性中,该属性价值将被传递到ItemCommand
事件处理程序。In your case, it would be better to use a normal hyperlink, pass the ID as query string, and have the new page get the details.
Update:
To get the studentID on the same page, use the ItemCommand event instead and have the
LinkButton
as follows:The studentID will be stored into the
CommandArgument
property, which value will be passed to theItemCommand
event handler.