首页 新闻 赞助 找找看

gridview绑定后取数据源列值

0
悬赏园豆:10 [已关闭问题] 关闭于 2011-05-05 15:04

我在绑定过后,再点击按钮来读取数据源的列值,像以下代码,但发现row.DataItem为空,导致拿出来的brand_id 也是空的。我发现repeater用这样的方式就可以拿出来,请指教。

For Each row As GridViewRow In grvApproveList.Rows

    dim brand_id as string = DataBinder.Eval(row.DataItem, "brand_id")

Next

佳乐比海的主页 佳乐比海 | 初学一级 | 园豆:70
提问于:2011-03-17 15:05
< >
分享
所有回答(1)
0
<%@ Page language="VB" %>

<script runat="server">

Sub AuthorsGridView_RowCreated(ByVal sender AsObject, ByVal e As GridViewRowEventArgs)

If e.Row.RowType = DataControlRowType.Footer Then

' Get the number of items in the Rows collection.
Dim count AsInteger= AuthorsGridView.Rows.Count

' If the GridView control contains any records, display
' the last name of each author in the GridView control.
If count >0Then

Message.Text
="The authors are:<br>"

Dim row As GridViewRow
ForEach row In AuthorsGridView.Rows

Message.Text
&= row.Cells(0).Text &"<br>"

Next

EndIf

EndIf

End Sub
邀月 | 园豆:25475 (高人七级) | 2011-03-17 20:35
你用row.Cells(0).Text是吗?但如果我的要读取的这个列不显示出来呢?
支持(0) 反对(0) 佳乐比海 | 园豆:70 (初学一级) | 2011-03-18 14:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册