Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="user.aspx.cs" Inherits="user" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">



<asp:SqlDataSource ID="dslist" runat="server" ConnectionString="Data Source=DIPTO\SQLEXPRESS;Initial Catalog=registration;Persist Security Info=True;User ID="cyclic order";Password=dipto012" ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [Transaction]">
<asp:ListView ID="ListView1" runat="server" DataKeyNames="Account_no." DataSourceID="dslist" EnableModelValidation="True" OnSelectedIndexChanged="ListView1_SelectedIndexChanged">
<alternatingitemtemplate>
<asp:Label ID="Account_no_Label" runat="server" Text='<%# Eval("Account_no.") %>' />
<asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>' />
<asp:Label ID="Dr_CrLabel" runat="server" Text='<%# Eval("[Dr/Cr]") %>' />
<asp:Label ID="Dr_Cr_AmmountLabel" runat="server" Text='<%# Eval("[Dr/Cr Ammount]") %>' />
<asp:Label ID="TotalLabel" runat="server" Text='<%# Eval("Total") %>' />

<edititemtemplate>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
<asp:TextBox ID="Account_no_TextBox" runat="server" Text='<%# Bind("Account_no.") %>' />
<asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>' />
<asp:TextBox ID="Dr_CrTextBox" runat="server" Text='<%# Bind("[Dr/Cr]") %>' />
<asp:TextBox ID="Dr_Cr_AmmountTextBox" runat="server" Text='<%# Bind("[Dr/Cr Ammount]") %>' />
<asp:TextBox ID="TotalTextBox" runat="server" Text='<%# Bind("Total") %>' />

<emptydatatemplate>
<table runat="server" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
No data was returned.

<insertitemtemplate>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
<asp:TextBox ID="Account_no_TextBox" runat="server" Text='<%# Bind("Account_no.") %>' />
<asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>' />
<asp:TextBox ID="Dr_CrTextBox" runat="server" Text='<%# Bind("[Dr/Cr]") %>' />
<asp:TextBox ID="Dr_Cr_AmmountTextBox" runat="server" Text='<%# Bind("[Dr/Cr Ammount]") %>' />
<asp:TextBox ID="TotalTextBox" runat="server" Text='<%# Bind("Total") %>' />

<itemtemplate>
<asp:Label ID="Account_no_Label" runat="server" Text='<%# Eval("Account_no.") %>' BorderStyle="Dashed" />
<asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>' />
<asp:Label ID="Dr_CrLabel" runat="server" Text='<%# Eval("[Dr/Cr]") %>' />
<asp:Label ID="Dr_Cr_AmmountLabel" runat="server" Text='<%# Eval("[Dr/Cr Ammount]") %>' />
<asp:Label ID="TotalLabel" runat="server" Text='<%# Eval("Total") %>' />

<layouttemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr runat="server" style="background-color:#DCDCDC;color: #000000;">
<th runat="server">Account_no.
<th runat="server">Date
<th runat="server">Dr/Cr
<th runat="server">Dr/Cr Ammount
<th runat="server">Total

<tr id="itemPlaceholder" runat="server">




<tr runat="server">
<td runat="server" style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">



<SelectedItemTemplate>
<asp:Label ID="Account_no_Label" runat="server" Text='<%# Eval("Account_no.") %>' />
<asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>' />
<asp:Label ID="Dr_CrLabel" runat="server" Text='<%# Eval("[Dr/Cr]") %>' />
<asp:Label ID="Dr_Cr_AmmountLabel" runat="server" Text='<%# Eval("[Dr/Cr Ammount]") %>' />
<asp:Label ID="TotalLabel" runat="server" Text='<%# Eval("Total") %>' />
</SelectedItemTemplate>

</form>
</body>
</html>
Posted
Updated 27-Feb-15 12:57pm
v2
Comments
Member 11439708 27-Feb-15 12:13pm    
USE [registration]
GO

SELECT [Account_no.]
,[Date]
,[Dr/Cr]
,[Dr/Cr Ammount]
,[Total]
FROM [dbo].[Transaction]
GO
Member 11439708 27-Feb-15 12:15pm    
The error message shows:


DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Account_no'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Account_no'.
sudevsu 27-Feb-15 13:16pm    
You should specify DATAVALUEFIELD and DATATEXTFIELD. Just giving DATASOURCE and Binding doesn't work. Don't think wrong me using CAPS. Just pasted it.
John C Rayan 27-Feb-15 13:59pm    
can you check that your connection string correct and datasource brings back the records.

My guess is that you have used "Account_no." everywhere and somewhere you have used "Account_no" (mark "." is not here). Please see and make it the same.
 
Share this answer
 
Thanks :).My problem is solved
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900