TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mahnaz af
NA
26
6.6k
how to get data from listview in asp.net
Jun 5 2015 2:19 AM
hi.i am trying to get values of listview in codebehind,but i dont know how do this.please help me.
<asp:ListView ID="ListView1" runat="server" DataKeyNames="pid" DataSourceID="SqlDataSource1"
GroupItemCount="3">
<GroupTemplate>
<tr id="itemPlaceholderContainer" runat="server">
<td id="itemPlaceholder" runat="server">
</td>
</tr>
</GroupTemplate>
<LayoutTemplate>
<table cellpadding="2" runat="server" border="1" style="border-collapse: collapse;
border-color: #999999; border-style: none; border-width: 1px;" id="tblProduct">
<tr runat="server" id="groupPlaceholder">
</tr>
</table>
<table align="center">
<tr id="r1" runat="server">
<td id="Td2" runat="server" style="text-align: center; background-color: #ffffff;
font-family: Verdana, Arial, Helvetica, sans-serif; color: #BA2323">
<asp:DataPager runat="server" ID="DataPager" PageSize="9">
<Fields>
<asp:NumericPagerField ButtonCount="6" PreviousPageText="<--" NextPageText="-->" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td id="Td1" valign="top" align="center" style="width: 100" runat="server">
<br /><asp:Label ID="lblpid" runat="server" Text='<%# Eval("pid") %>' />
<asp:Label ID="titleLabel" runat="server" Text='<%# Eval("title") %>' />
<br />
<asp:Image ID="Image1" runat="server" src='<%# Eval("tozihat") %>' />
<br />
<asp:Label ID="lblprice" runat="server" Text='<%# Eval("price") %>'></asp:Label>
<br />
<br />
<asp:PlaceHolder ID="AvailPlaceHolder" runat="server" Visible=<%# (Eval("mojoud") == "a") %>>
<tr>
<td>
<asp:Label ID="lblAvail" runat="server" Text="????? ???"></asp:Label>
</td>
<td colspan="27">
</td>
</tr>
</asp:PlaceHolder>
<br />
<asp:TextBox ID="txtcount" type="text" runat="server" Width="30"></asp:TextBox>
<asp:Button ID="addtobasket" runat="server" Text="Add to basket" OnClick="addtobasket_Click">
</asp:Button>
<br />
<asp:HyperLink ID="HyperLink2" runat="server" Target="_blank" NavigateUrl='<%#"Continue.aspx?pid=" + Eval("pid") %>'>...??????? ????? </asp:HyperLink>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
i use this code:
TextBox countText = (TextBox)item .FindControl("txtcount");
but program error that:
Compiler Error Message:
CS0103: The name 'item' does not exist in the current context
Source Error:
Line 40: Line 41: Line 42: TextBox countText = (TextBox)item .FindControl("txtcount");
Reply
Answers (
11
)
Difference bw ref and out key word in c#
.Bcc Email