AdmiralGanja
-
Total Posts
:
6
- Scores: 0
-
Reward points
:
0
- Joined: 3/11/2007
-
Status: offline
|
Dynamic tables... Best way of Conduct!
Wednesday, March 14, 2007 7:48 PM
( permalink)
Hi, Im working with this VB ASP.NET application and i just wanted some tip! I am working a lot with tables that are filled with data from the database. Currently the solution is made in VBscript and using lots of loops and lots of "if" that then <td> and such statements and, just too much hard to understand, far to complex code. What is the best way to do this? It has got to exsist a simple solution?! Depending on the users configuration, the tables will show a variaty of different column combinations. (The user chooses the columns to be viewed in the configuration.). Should i use views for this? This would result in far to many views to cover all combinations? Please give me a hint for y web application =) Kind Regards/Admiral
|
|
|
|
TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
RE: Dynamic tables... Best way of Conduct!
Sunday, May 11, 2008 4:02 PM
( permalink)
What do you mean the solution is made in VBScript? I thought you were using VB.NET? Are you using VBScript in the client browser? Why don't you just have the pages react to user column actions by executing a function on the server that executes an SQL binding query? I don't have any idea how your page is set up, but my thought was something like this:
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
sub Page_Load
dim dbconn,sql,dbcomm,dbread
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
data source=" & server.mappath("northwind.mdb"))
dbconn.Open()
sql="SELECT * FROM customers"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
customers.DataSource=dbread
customers.DataBind()
dbread.Close()
dbconn.Close()
end sub
</script>
<html>
<body>
<form runat="server">
<asp:Repeater id="customers" runat="server">
<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>Companyname</th>
<th>Contactname</th>
<th>Address</th>
<th>City</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Container.DataItem("companyname")%></td>
<td><%#Container.DataItem("contactname")%></td>
<td><%#Container.DataItem("address")%></td>
<td><%#Container.DataItem("city")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
</body>
</html>
Depending on user action, have a server side function that generates different table templates. I would think this should reduce the thought complexity involved.
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|