且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将数据绑定到listview

更新时间:2022-10-15 07:42:25

使用以下格式:



 <   asp:textbox     id   =  txtlistnum     runat   =  server    backcolor   =  Aqua    text   =  <%# EV al(  ListNumber)%>    xmlns:asp   = #未知    /  >  





您可以在此处查看此链接Asp.net ListView - DataBinding [ ^ ]





更不用说你需要使用一些数据源,其中填充了你想要显示的数据,即数据表,对象列表等,然后将它绑定到列表视图。



问候

Pawan


试试这个

ListView Web服务器控件概述 [ ^ ]

您唯一的数据绑定控件需要 [ ^ ]

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Listview.aspx.cs" Inherits="Listview" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="height: 721px">
        <asp:ListView ID="ListView1" runat="server" >
        <layouttemplate>
        <asp:PlaceHolder ID="itemplaceholder" runat="server">                    
        </layouttemplate>
        <itemtemplate>
        <table>
        <tr id="itemplaceholderid"  runat="server" >
        <td>
        <asp:Label ID="lbllistnum" runat="server" Text="Number" />
        <asp:TextBox ID="txtlistnum" runat="server"  BackColor="Aqua" />
        <asp:CheckBox ID="chklistacc" runat="server" Text="Accept" />
        <asp:CheckBox ID="chklistrej" runat="server" Text="Reject" />
        </td></table></itemtemplate></div><asp:Button ID="btnlistsave" runat="server" Text="SAVE" onclick="btnlistsave_Click" />
    </form>
</body>
</html>





I have to bind the data to textbox help me out with the code...

use the following format:

<asp:textbox id="txtlistnum" runat="server" backcolor="Aqua" text="<% #Eval("ListNumber")%>" xmlns:asp="#unknown" />



You can check this link here Asp.net ListView - DataBinding[^] on how to bind data to listview


Not to mention you need to use some datasource which is populated with the data you want to show i.e., datatable, List of objects etc and then bind it to the listview.

Regards
Pawan


try this
ListView Web Server Control Overview[^]
The Only Data-binding Control You''ll Ever Need[^]