Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 12th, 2004, 02:35 AM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataList - NOT WORKING FOR ME


Need help creating a DataList (or its template) and then binding it to the data.

Data is in a SQL 2000 Server Database....if anyone can help me with what I can do it would be great.

Regards
Ryan

 
Old March 14th, 2004, 12:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

I hope this sample can help u.
Code:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<Script Runat="Server">
  void Page_Load( Object s, EventArgs e )
  {
    SqlConnection myConnection;
    SqlCommand myCommand;
    myConnection = new SqlConnection( "Server=Localhost;uid=sa;Database=Northwind" );
    myCommand = new SqlCommand( "Select CategoryName from Categories", myConnection );
    myConnection.Open();
    myDataList.DataSource = myCommand.ExecuteReader();
    myDataList.DataBind();
    myConnection.Close();
  }
</Script>

<html>
<head><title>Categories</title></head>
<body>

<form Runat="Server">
<asp:DataList id="myDataList" RepeatLayout="Flow" Runat="Server">
  <ItemTemplate>
     <a href=mailto:<%# DataBinder.Eval( Container.DataItem, "CategoryName" ) %>><%# DataBinder.Eval( Container.DataItem, "CategoryName" ) %></a>
  </ItemTemplate>
</asp:DataList>
</form>

</body>
</html>
Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Datalist inside datalist amit.jagtap ASP.NET 2.0 Professional 1 September 4th, 2007 05:03 AM
window.opener working .... not working alyeng2000 Javascript How-To 5 January 5th, 2007 08:05 AM
Web.Config..Working or Not Working peace95 ASP.NET 1.0 and 1.1 Basics 1 September 18th, 2006 06:53 AM
Local COM working , but not working at Web Serv nagen111 .NET Web Services 3 February 19th, 2005 04:22 AM
Datalist editing not working cjcd ASP.NET 1.0 and 1.1 Basics 4 April 3rd, 2004 07:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.