从ListView1中选择数据并在ListView2中显示它 [英] Select data from ListView1 and Display it in ListView2
问题描述
你好,
-我在网页上有2个ListView。 ListView1与数据库连接,
-I想要使用Checkbox选择一行
-and on ButtonClick我想在ListView2中显示所选数据。
-Answers请。
< asp:ListView ID =ListView1runat =serverDataSourceID =TestSqlDataSource
DataKeyNames =id>
< itemtemplate>
< asp:CheckBox ID =chckSelectOnCheckedChanged = getRow_OnCheckedChangedCssClass =TextBoxrunat =server/>
< asp:Label ID =lblIDrunat =serverText ='<%#Eval(id )%>'/>
< asp:标签ID =lblNamerunat =serverText ='<%#Eval(name)%>'/> ;
< asp:TextBox ID =txtLocationrunat =serverCssClass =TextBox Text ='<%#Eval(location)%>'>
< layouttemplate>
< table runat =server>
< tr runat =server>
< ; td id =Td1runat =server>
< table ID =itemPlaceholderContainerrunat =serverborder =2style =>
< tr id =Tr1runat =serverstyle =>
< th id =Th1runat =server>
< asp:Label ID =selrunat =serverCssClass =DialogHeader>
< th id =Th2 runat =server>
< asp:Label ID =NamelblWidth =100pxrunat =serverText =IDCssClass =DialogHeader>
< th id =Th3runat =server>
< asp:Label ID =LoclblWidth =200pxrunat =serverText =NameCssClass = DialogHeader>
< th id =Th4runat =server>
< asp:标签ID =ETimelblrunat =serverWidth =155pxText =LocationCssClass =DialogHeader>
< tr ID =itemPlaceholderrunat =server>
< asp :DataPager runat =serverID =DataPagerPageSize =10>
< fields>
< asp:NumericPagerField
ButtonCount =5
PreviousPageText =< -
NextPageText = - > />
< asp:Button ID =btnMove runat =serverText =>>
onclick =btnMove_Click/>
Hello,
-I have 2 ListView on a WebPage. ListView1 is connected with the data base,
-I want to select a Row using Checkbox
-and on ButtonClick I want to display selected data in ListView2.
-Answers Please.
<asp:ListView ID="ListView1" runat="server" DataSourceID="TestSqlDataSource"
DataKeyNames="id">
<itemtemplate>
<asp:CheckBox ID="chckSelect" OnCheckedChanged="getRow_OnCheckedChanged" CssClass="TextBox" runat="server" />
<asp:Label ID="lblID" runat="server" Text='<%# Eval("id") %>' />
<asp:Label ID="lblName" runat="server" Text='<%# Eval("name") %>' />
<asp:TextBox ID="txtLocation" runat="server" CssClass="TextBox" Text='<%# Eval("location") %>'>
<layouttemplate>
<table runat="server">
<tr runat="server">
<td id="Td1" runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="2" style="">
<tr id="Tr1" runat="server" style="">
<th id="Th1" runat="server">
<asp:Label ID="sel" runat="server" CssClass="DialogHeader">
<th id="Th2" runat="server">
<asp:Label ID="Namelbl" Width="100px" runat="server" Text="ID" CssClass="DialogHeader">
<th id="Th3" runat="server">
<asp:Label ID="Loclbl" Width="200px" runat="server" Text="Name" CssClass="DialogHeader">
<th id="Th4" runat="server">
<asp:Label ID="ETimelbl" runat="server" Width="155px" Text="Location" CssClass="DialogHeader">
<tr ID="itemPlaceholder" runat="server">
<asp:DataPager runat="server" ID="DataPager" PageSize="10">
<fields>
<asp:NumericPagerField
ButtonCount="5"
PreviousPageText="<--"
NextPageText="-->"/>
<asp:Button ID="btnMove" runat="server" Text=">>"
onclick="btnMove_Click" />
< asp:ListView ID =ListView2runat =server>
< layouttemplate>
< table id =Table1runat =server >
< tr id =Tr2runat =server>
< ; td id =Td1runat =server>
< table ID =itemPlaceholderContainerrunat =serverborder =2style =>
< tr id =Tr1runat =serverstyle =>
< th id =Th1runat =server>
< asp:Label ID =lblIDWidth =100pxrunat =serverText =IDCssClass =DialogHeader>
< th id =Th2runat =server>
< asp:Label ID =lblNameWidth =200pxrunat =serverText =NameCssClass =DialogHeader>
< th id =Th3runat =server>
< asp:Label ID =lblLocationrunat =serverWidth =155pxText =LocationCssClass =DialogHeader >
< tr ID =itemPlaceholderrunat =server>
< itemtemplate>
< asp:Label ID =lbID2runat =serverText ='<%#Eval(id2)%>'/>
< asp:Label ID =lblName2runat =服务器Text ='<%#Eval(name2)%>'/>
< asp:TextBox ID =txtLocation2runat =serverCssClass =TextBoxText ='<%#Eval(location2)%>'>
<asp:ListView ID="ListView2" runat="server">
<layouttemplate>
<table id="Table1" runat="server">
<tr id="Tr2" runat="server">
<td id="Td1" runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="2" style="">
<tr id="Tr1" runat="server" style="">
<th id="Th1" runat="server">
<asp:Label ID="lblID" Width="100px" runat="server" Text="ID" CssClass="DialogHeader">
<th id="Th2" runat="server">
<asp:Label ID="lblName" Width="200px" runat="server" Text="Name" CssClass="DialogHeader">
<th id="Th3" runat="server">
<asp:Label ID="lblLocation" runat="server" Width="155px" Text="Location" CssClass="DialogHeader">
<tr ID="itemPlaceholder" runat="server">
<itemtemplate>
<asp:Label ID="lbID2" runat="server" Text='<%# Eval("id2") %>' />
<asp:Label ID="lblName2" runat="server" Text='<%# Eval("name2") %>' />
<asp:TextBox ID="txtLocation2" runat="server" CssClass="TextBox" Text='<%# Eval("location2") %>'>
推荐答案
试试这个:
http://stackoverflow.com/questions/2340439/how-to-copy-the-selected-items-from-one-listview-to-another-on-button-click-in-c [ ^ ]
这篇关于从ListView1中选择数据并在ListView2中显示它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!