Prashant Malav

Prashant Malav

  • NA
  • 80
  • 19.7k

display Id, Title, price,code and Image folder in DataList.

Dec 3 2015 11:58 PM
Hello
 
 I need to display Id, Title, price,code and Image folder in DataList.
 
Please help me...
 aspx
<asp:DataList ID="dtlist" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
<ItemTemplate>
<li>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("sproduct_code") %>' Font-Bold="True" Font-Size="1.2em" ForeColor="Navy"/><br />
<asp:Label ID="Label2" runat="server" Text='<%# Eval("sproduct_title") %>' Font-Italic="true"/><br />
<asp:Label ID="Label3" runat="server" Text='<%# "Price: US$"+System.Convert.ToString(Eval("retail_price")) %>' Font-Bold="True" Font-Size="1.2em" ForeColor="Navy"/><br />
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "datalistpage.aspx?id=" + System.Convert.ToString(Eval("nproduct_id")) %>'/>

</li>

</ItemTemplate>

</asp:DataList> 
 
 
aspx.cs
if (!Page.IsPostBack)
{
string connectionString = ConfigurationManager.ConnectionStrings["indConnStr"].ConnectionString;
DataTable dt = new DataTable();
SqlConnection conn = new SqlConnection(connectionString);
using (conn)
{
SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM product", conn);
ad.Fill(dt);
}
dtlist.DataSource = dt;
dtlist.DataBind();
 
 web.config
<connectionStrings>
<add name="indConnStr" connectionString="Data Source=CODER\\SQLEXPRESS;Integrated Security=true;Initial Catalog=DBNAME" providerName="System.Data.SqlClient"/>
</connectionStrings> 
 
error show:-

Instance failure.

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.InvalidOperationException: Instance failure.

Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

<%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your application:

<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>

Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

Stack Trace:
 
 

Answers (1)