how would one go about loading up sql data into an asp.net (without using dataview, formview, detailsview etc)? any ideas? have my table marked up already and connection strings just need to know how to put the two together. Thanks for your time

Why would you not use the web controls?

Look at the System.Web.UI.HtmlControls namespace there's HtmlTable objects and HtmlTabkleRow and HtmlTableCell, just foreach your DataTable into HtmlTable controls and add to the Page.Controls collectio or a PlaceHolder.Controls collection.


Do you know about the repeater control?

Are you using framework 3.5? it has the new ListView which is like a repeater on steriods !! it's the Dogs Kahoonas.

lol thanks for your reply, unfortunately am using 2.0 of the framework (wow!). Have a pretty good idea of what to do now though will keep you updated cheers

unfortunately am using 2.0 of the framework (wow!).

Well that's what 90% if the software world is using. Hell I'm still maintaining Framework 1.1 projects.

Back in the time of classic ASP, one day I found myself conactenating <tr> <td> tags in a loop for a recordset in VBScript for the umpteenth time (I was still a fairly green coder then) when I suddenly realised "Hey! the computer should be doing the work, I'm bored of typing strHTML = strHTML & "<some tag> blah..."

I had just discovered what OOP meant and what a Class was and that VBScript could do classes (to certain extent.) So I made one that concatenated <tr> <td> tags (eventually I made it do subtotal rows and all sorts but that's another story) so from then on I just passed the recordset object to my table class and asked it to WriteTable().

Of course lots of other developers were doing this too. That's why webcontrols exist in .NET, and that's why I struggle with the concept of ever not wanting to just do Control.DataSource = dt; Control.DataBind(); But I guess that's because the novelty of seeing my carefully concatenated HTML rendered in a page has worn off now, when it was a new concept I though it was great.

cool, well thanks for the reply. BTW in reply to your ealir question I am not using web controls (like formview etc) because I have already tried them (I am using vista home basic) and bound them to sql d/b but they are not visible on the web page :-(

I can't understand why you can't get web controls to appear on the page. Can you post some code?

p.s. Do you know about the empty data template?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="a.aspx.cs" Inherits="Restricted_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD html 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0047)http://localhost:51704/blah/LoginPage.aspx -->
<html xmlns="http://www.w3.org/1999/xhtml"><head><title runat="server" > - a Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta content="MShtml 6.00.6000.16587"  name="GENERATOR"/><link rel="stylesheet" type="text/css" href="demo.CSS" runat="server" /></head>



<body runat="server" >
<form id="a" runat="server" >
<div >

<h1 runat="server" visible="true">You are logged in </h1>
    <h1 runat="server" visible="true">
        with the following details:</h1>




<p>
    &nbsp;<asp:Table ID="Table1" runat="server"  >
        <asp:TableRow runat="server" >
            <asp:TableCell runat="server"></asp:TableCell>
            <asp:TableCell runat="server"></asp:TableCell>
            <asp:TableCell runat="server"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow runat="server">
            <asp:TableCell runat="server"></asp:TableCell>
            <asp:TableCell runat="server"></asp:TableCell>
            <asp:TableCell runat="server"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow runat="server">
            <asp:TableCell runat="server"></asp:TableCell>
            <asp:TableCell runat="server"></asp:TableCell>
            <asp:TableCell runat="server"></asp:TableCell>
        </asp:TableRow>
    </asp:Table>
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="username"
        DataSourceID="SqlDataSource1" Height="50px" Width="125px">
        <Fields>
            <asp:BoundField DataField="username" HeaderText="username" SortExpression="username" />
            <asp:BoundField DataField="role" HeaderText="role" SortExpression="role" />
            <asp:BoundField DataField="email" HeaderText="email" SortExpression="email" />
            <asp:BoundField DataField="tel" HeaderText="tel" SortExpression="tel" />
            <asp:BoundField DataField="fax" HeaderText="fax" SortExpression="fax" />
            <asp:BoundField DataField="organisation" HeaderText="organisation" SortExpression="organisation" />
        </Fields>
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:demoConnectionString5 %>"
        SelectCommand="SELECT [username], [role], [email], [tel], [fax], [organisation] FROM [users] WHERE ([username] = @username)">
        <SelectParameters>
            <asp:Parameter Name="username" Type="String"  />
        </SelectParameters>
    </asp:SqlDataSource>
    &nbsp;</p>
    <p>
        If any of your details are incorrect,you can request to update them by clicking below</p>
<input style="WIDTH: 130px" type="submit" value="Update my details" id="Label3"/>


<h1>Please select the type of data you would<br/>
    like to submit an Update request for:</h1>

    <h2>
        <asp:Button ID="Button1" runat="server" Text="Log out" Font-Underline="False" />&nbsp;</h2>



</div>
</form>
</body></html>
This question has already been answered. Start a new discussion instead.