将数据绑定到listview [英] Binding Data to listview

查看:59
本文介绍了将数据绑定到listview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ Page Language =C#AutoEventWireup =trueCodeFile =Listview.aspx.csInherits =Listview%> 
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://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 =form1runat =server>
< div style =height:721px>
< asp:ListView ID =ListView1runat =server>
< layouttemplate>
< asp:PlaceHolder ID =itemplaceholderrunat =server>
< / layouttemplate>
< itemtemplate>
< table>
< tr id =itemplaceholderidrunat =server>
< td>
< asp:Label ID =lbllistnumrunat =serverText =Number/>
< asp:TextBox ID =txtlistnumrunat =serverBackColor =Aqua/>
< asp:CheckBox ID =chklistaccrunat =serverText =Accept/>
< asp:CheckBox ID =chklistrejrunat =serverText =Reject/>
< / td>< / table>< / itemtemplate>< / div>< asp:按钮ID =btnlistsaverunat =serverText =SAVEonclick =btnlistsave_Click/ >
< / form>
< / body>
< / html>









我有将数据绑定到文本框帮助我解决代码...

解决方案

使用以下格式:



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





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





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



问候

Pawan


< blockquote>试试这个

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[^]


这篇关于将数据绑定到listview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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