在变量中获得价值 [英] To get value in a variable
本文介绍了在变量中获得价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取变量中单元格的值
我的vb编码在下面给出
How to get value of cell in a variable
my vb coading is given below
Protected Sub gvShape_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvShape.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
For c As Integer = 0 To gvShape.Columns.Count - 1
Dim shapeid As String = CType(e.Row.Cells(c).FindControl("lbl_col_" & c + 1), Label).Text
e.Row.Cells(c).Attributes.Add("onDblClick", String.Format("popup('{0}')", shapeid))
e.Row.Cells(c).Attributes.Add("onClick", String.Format("select({0},{1},'{2}')", e.Row.RowIndex, c, shapeid))
Next
End If
End Sub
推荐答案
您首先要找出
System.Web.UI.WebControls.GridViewRowEventArgs
[ ^ ]最好是通过谷歌搜索来实现.在该页面上,您会发现此事件参数具有行 [ ^ ]属性.此Row属性的类型为GridViewRow
[ ^ ]其中您会找到Cells
[[ ^ ].
我们快到了,等等.现在,这取决于表单元格的内容.表格单元格可以包含相当多的view内容,其中之一是文本,因此访问此属性称为 ^ ].该TableCell可能还包含其他控件,那么您必须使用 ^ ]属性即可访问这些属性.
最好的选择是调试应用程序,并查看网格视图中包含的实时数据.
最好的问候,
曼弗雷德(Manfred)
You start by finding out what
System.Web.UI.WebControls.GridViewRowEventArgs
[^] is preferably by googling for it. On that page you''ll find that this event argument has a Row[^] property. This Row property is of typeGridViewRow
[^] where you find theCells
[^] indexed property. This yields aTableCellCollection
and one of the contained items is aTableCell
[^].
We''re almost there, hold on. Now it depends what the content of your table cell is. There are quite aviewfew things a table cell can contain and one of them is text and thus the property to access this is called Text[^]. It might be as well that this TableCell contains other controls then you''d have to use the Controls[^] property to access those.
Your best bet would be to debugg your application and have a look at the live data contained in your grid view.
Best Regards,
Manfred
这篇关于在变量中获得价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文