根据网格视图的选定行更改两个标签的文本
我想根据网格视图的选定行更改两个标签的文本。
我不断收到错误消息,指出链接按钮上不存在公共成员行
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim LinkButton1 As LinkButton = DirectCast(sender, LinkButton)
Dim tour As Label = CType(sender.Row.FindControl("label2"), Label)
Dim depart As Label = CType(sender.Row.FindControl("label3"), Label)
test.Text = tour.Text
test1.Text = depart.Text
UpdatePanel9.Update()
End Sub
I want to change the text of two labels based on the selected row of a gridview.
I keep getting an error that says the public member row does not exist on linkbutton
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim LinkButton1 As LinkButton = DirectCast(sender, LinkButton)
Dim tour As Label = CType(sender.Row.FindControl("label2"), Label)
Dim depart As Label = CType(sender.Row.FindControl("label3"), Label)
test.Text = tour.Text
test1.Text = depart.Text
UpdatePanel9.Update()
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的代码,
sender
是一个LinkButton
。当您引用sender.Row
时,链接按钮上将不存在Row
属性。这就是您收到错误的原因。您想要挂钩 SelectedIndexChanged 事件,这将使您可以更轻松地访问该行。
According to your code,
sender
is aLinkButton
. The propertyRow
won't exist on a link button when you referencesender.Row
. That's why you get the error.You want to hook into the SelectedIndexChanged event, which will give you access to the Row more easily.