| | |
load sql data into asp.net table
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
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
Computers are man's attempt at designing a cat: It does whatever it wants, whenever it wants, and rarely ever at the right 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.
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.
•
•
•
•
unfortunately am using 2.0 of the framework (wow!).
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 :-(
Computers are man's attempt at designing a cat: It does whatever it wants, whenever it wants, and rarely ever at the right time.
http://www.daniweb.com/forums/thread109968.html
is my previous thread
is my previous thread
Computers are man's attempt at designing a cat: It does whatever it wants, whenever it wants, and rarely ever at the right time.
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?
p.s. Do you know about the empty data template?
Last edited by hollystyles; Feb 25th, 2008 at 6:55 am.
ASP.NET Syntax (Toggle Plain Text)
<%@ 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> <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> </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" /> </h2> </div> </form> </body></html>
Computers are man's attempt at designing a cat: It does whatever it wants, whenever it wants, and rarely ever at the right time.
![]() |
Similar Threads
- sql query problem with MS Access and C# (C#)
- Simple ASP.Net Login Page using C# (C#)
- ASP.NET Registration Page (ASP.NET)
- How can i retrieve data after i logod on..... (ASP.NET)
- ASP.Net Security 101 Part 1 (ASP.NET)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- Populating & Retrieving Data in a listbox : ASP.NET (w/ VB.NET) (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Dreamweaver problem...
- Next Thread: Object reference not set to an instance of an object
| Thread Tools | Search this Thread |
.net 2.0 activexcontrol advice ajax alltypeofvideos appliances application asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions css dataaccesslayer database datagridview datagridviewcheckbox datalist development dgv dialog dropdownlist dynamically edit expose feedback fileuploader fill flash form formatdecimal formview google grid gridview gudi iframe iis image javascript listbox login microsoft mono mouse mssql multistepregistration news numerical opera panelmasterpagebuttoncontrols parent radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security select sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking treeview unauthorized validatedate validation vb.net video videos view virtualdirectory vista visualstudio web webapplications webdevelopemnt webprogramming webservice xsl youareanotmemberofthedebuggerusers






