S
Stephanie_Stowe
Hi. I am trying to get used to AS.NET. I have been doing ASP classic for
years, and am now in a position to do ASP.NET. I am in the stumbling
around until I get my bearings phase. I hope you will bear with me. I am
going through the QuickStart. After reading a little, I am trying to
implement a simple page on a simple project I have made up. I have a page
called default.aspx. I want it to load a list of user names from a SQL
database when the page loads.
Observe this from the HTML view
<asp:datalist id=dlUsers runat="server" BorderColor="#C00000" BorderStyle="Double"></asp
ataList>
(I added the border because I could not tell if the datalist was absent or
the data which should be IN the datalist.
Observe the underlying class code:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
String connectionString = "Initial
Catalog=Grocery;Data Source=localhost;user=Grocery";
DataSet ds = new DataSet();
SqlConnection cn = new SqlConnection(connectionString);
cn.Open();
//SqlCommand cmd = new SqlCommand("Select * From UserQualifiedName", cn);
//cmd.CommandType = CommandType.Text;
String select = "SELECT UserID, LastName + ', ' +
FirstName AS Name FROM dbo.[User]";
SqlDataAdapter da = new SqlDataAdapter(select, cn);
da.Fill(ds);
dlUsers.DataSource = ds;
dlUsers.DataBind();
}
This code runs, but it does not list in the datalist. The datalist
displays as I see a tiny red box completely empty of content. I am not
seeing any methods for the SqlDataAdapter like Open or Make It So Number
1. There is defintely a record in the table in question.
Can anyone give me a nudge on what I might be doing wrong? My handy dandy
ASP.NET books won't arrive from amazon until tomorrow.
Thanks!
S
years, and am now in a position to do ASP.NET. I am in the stumbling
around until I get my bearings phase. I hope you will bear with me. I am
going through the QuickStart. After reading a little, I am trying to
implement a simple page on a simple project I have made up. I have a page
called default.aspx. I want it to load a list of user names from a SQL
database when the page loads.
Observe this from the HTML view
<asp:datalist id=dlUsers runat="server" BorderColor="#C00000" BorderStyle="Double"></asp

(I added the border because I could not tell if the datalist was absent or
the data which should be IN the datalist.
Observe the underlying class code:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
String connectionString = "Initial
Catalog=Grocery;Data Source=localhost;user=Grocery";
DataSet ds = new DataSet();
SqlConnection cn = new SqlConnection(connectionString);
cn.Open();
//SqlCommand cmd = new SqlCommand("Select * From UserQualifiedName", cn);
//cmd.CommandType = CommandType.Text;
String select = "SELECT UserID, LastName + ', ' +
FirstName AS Name FROM dbo.[User]";
SqlDataAdapter da = new SqlDataAdapter(select, cn);
da.Fill(ds);
dlUsers.DataSource = ds;
dlUsers.DataBind();
}
This code runs, but it does not list in the datalist. The datalist
displays as I see a tiny red box completely empty of content. I am not
seeing any methods for the SqlDataAdapter like Open or Make It So Number
1. There is defintely a record in the table in question.
Can anyone give me a nudge on what I might be doing wrong? My handy dandy
ASP.NET books won't arrive from amazon until tomorrow.
Thanks!
S