如何在ListView vb.net中绑定值 [英] How to bind the Value In ListView vb.net

查看:282
本文介绍了如何在ListView vb.net中绑定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai我正在使用列表视图我正在绑定表中的值,但它没有显示下面是我的代码请帮我解决这个问题:

Vb.code是

  Dim  oDt2 作为  New  DataTable 
oDr = oMainForm.oConn.RunQuery( Select * from test
oDt2.Load(oDr)
ConversationListView.DataSource = oDt2
oDr.Close()







用户界面是:



  <   asp:ListView     ID   =  ConversationListView    runat   =   server >  
< InsertItemTemplate >
< tr >
< td >
< asp:标签 runat = server ID = id <跨越ss =code-attribute> 文字 =' <% #Eval( id %> ' > < / asp:标签 >
< / td >
< span class =code-keyword>< td >
< asp:标签 runat = 服务器 ID = message 文本 =' <% #Eval( message%> ' > < / asp:标签 >
< / td >
< / tr >
< / InsertItemTemplate >
< / asp:ListView < span class =code-keyword>>

解决方案

hi


当你获得数据表或数据集时使用以下代码在listview中添加项目

ds =数据集从数据库中获取

 < span class =code-keyword>对于 intI =  0    ds.Tables(  0 )。Rows.Count  -   1  
.ListView1.Items.Add(ds.Tables( 0 )。行(intI).Item( 0 ))
下一步


Hai I am using List view i am binding the Value from a table but it's not showing Below is my code Please Help me for this issue :
Vb.code is

Dim oDt2 As New DataTable
        oDr = oMainForm.oConn.RunQuery("Select * from test")
        oDt2.Load(oDr)
        ConversationListView.DataSource = oDt2
        oDr.Close()




UI is:

<asp:ListView ID="ConversationListView" runat="server">
                        <InsertItemTemplate>
                            <tr>
                                <td>
                                    <asp:Label runat="server" ID="id" Text='<%# Eval("id") %>'></asp:Label>
                                </td>
                                <td>
                                    <asp:Label runat="server" ID="message" Text='<%# Eval("message") %>'></asp:Label>
                                </td>
                            </tr>
                        </InsertItemTemplate>
                    </asp:ListView>

解决方案

hi
when u get datatable or dataset use following code for add items in listview
ds = dataset which u get from your database

For intI = 0 To ds.Tables(0).Rows.Count - 1
     Me.ListView1.Items.Add(ds.Tables(0).Rows(intI).Item(0))
Next


这篇关于如何在ListView vb.net中绑定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆