load sql data into asp.net table

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2007
Posts: 1,296
Reputation: majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about 
Solved Threads: 67
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Nearly a Posting Virtuoso

load sql data into asp.net table

 
0
  #1
Feb 22nd, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: load sql data into asp.net table

 
0
  #2
Feb 22nd, 2008
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.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,296
Reputation: majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about 
Solved Threads: 67
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Nearly a Posting Virtuoso

Re: load sql data into asp.net table

 
0
  #3
Feb 22nd, 2008
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
Computers are man's attempt at designing a cat: It does whatever it wants, whenever it wants, and rarely ever at the right time.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: load sql data into asp.net table

 
0
  #4
Feb 22nd, 2008
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.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,296
Reputation: majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about 
Solved Threads: 67
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Nearly a Posting Virtuoso

Re: load sql data into asp.net table

 
0
  #5
Feb 22nd, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,296
Reputation: majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about 
Solved Threads: 67
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Nearly a Posting Virtuoso

Re: load sql data into asp.net table

 
0
  #6
Feb 22nd, 2008
Computers are man's attempt at designing a cat: It does whatever it wants, whenever it wants, and rarely ever at the right time.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: load sql data into asp.net table

 
0
  #7
Feb 22nd, 2008
I've replied in your other thread.

How are you 'Browsing' your ASP.NET app ?
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,296
Reputation: majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about 
Solved Threads: 67
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Nearly a Posting Virtuoso

Re: load sql data into asp.net table

 
0
  #8
Feb 25th, 2008
via the asp.net integrated dev server why ?hav some ideas ?
Computers are man's attempt at designing a cat: It does whatever it wants, whenever it wants, and rarely ever at the right time.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: load sql data into asp.net table

 
0
  #9
Feb 25th, 2008
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?
Last edited by hollystyles; Feb 25th, 2008 at 6:55 am.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,296
Reputation: majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about 
Solved Threads: 67
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Nearly a Posting Virtuoso

Re: load sql data into asp.net table

 
0
  #10
Feb 25th, 2008
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="a.aspx.cs" Inherits="Restricted_Default" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD html 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
  4. <!-- saved from url=(0047)http://localhost:51704/blah/LoginPage.aspx -->
  5. <html xmlns="http://www.w3.org/1999/xhtml"><head><title runat="server" > - a Page</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  7. <meta content="MShtml 6.00.6000.16587" name="GENERATOR"/><link rel="stylesheet" type="text/css" href="demo.CSS" runat="server" /></head>
  8.  
  9.  
  10.  
  11. <body runat="server" >
  12. <form id="a" runat="server" >
  13. <div >
  14.  
  15. <h1 runat="server" visible="true">You are logged in </h1>
  16. <h1 runat="server" visible="true">
  17. with the following details:</h1>
  18.  
  19.  
  20.  
  21.  
  22. <p>
  23. &nbsp;<asp:Table ID="Table1" runat="server" >
  24. <asp:TableRow runat="server" >
  25. <asp:TableCell runat="server"></asp:TableCell>
  26. <asp:TableCell runat="server"></asp:TableCell>
  27. <asp:TableCell runat="server"></asp:TableCell>
  28. </asp:TableRow>
  29. <asp:TableRow runat="server">
  30. <asp:TableCell runat="server"></asp:TableCell>
  31. <asp:TableCell runat="server"></asp:TableCell>
  32. <asp:TableCell runat="server"></asp:TableCell>
  33. </asp:TableRow>
  34. <asp:TableRow runat="server">
  35. <asp:TableCell runat="server"></asp:TableCell>
  36. <asp:TableCell runat="server"></asp:TableCell>
  37. <asp:TableCell runat="server"></asp:TableCell>
  38. </asp:TableRow>
  39. </asp:Table>
  40. <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="username"
  41. DataSourceID="SqlDataSource1" Height="50px" Width="125px">
  42. <Fields>
  43. <asp:BoundField DataField="username" HeaderText="username" SortExpression="username" />
  44. <asp:BoundField DataField="role" HeaderText="role" SortExpression="role" />
  45. <asp:BoundField DataField="email" HeaderText="email" SortExpression="email" />
  46. <asp:BoundField DataField="tel" HeaderText="tel" SortExpression="tel" />
  47. <asp:BoundField DataField="fax" HeaderText="fax" SortExpression="fax" />
  48. <asp:BoundField DataField="organisation" HeaderText="organisation" SortExpression="organisation" />
  49. </Fields>
  50. </asp:DetailsView>
  51. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:demoConnectionString5 %>"
  52. SelectCommand="SELECT [username], [role], [email], [tel], [fax], [organisation] FROM [users] WHERE ([username] = @username)">
  53. <SelectParameters>
  54. <asp:Parameter Name="username" Type="String" />
  55. </SelectParameters>
  56. </asp:SqlDataSource>
  57. &nbsp;</p>
  58. <p>
  59. If any of your details are incorrect,you can request to update them by clicking below</p>
  60. <input style="WIDTH: 130px" type="submit" value="Update my details" id="Label3"/>
  61.  
  62.  
  63. <h1>Please select the type of data you would<br/>
  64. like to submit an Update request for:</h1>
  65.  
  66. <h2>
  67. <asp:Button ID="Button1" runat="server" Text="Log out" Font-Underline="False" />&nbsp;</h2>
  68.  
  69.  
  70.  
  71. </div>
  72. </form>
  73. </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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC