how do I present sql data in tabular format using asp.net

R

rob merritt

hi I have been trying to put data I retrived from a sql db into a
tabular
format I tried <asp:table , but it appears I cant databind to it so
then
I tried to use simple html <table> and bind to the page and display
the
record elements any hints for me?




<%@ Page Language="VB" Inherits="bookingFunctions"
Src="bookingCode.vb" %>
<script runat="server">

Public strQuery as String = ""

Private Sub Page_Load(sender as Object, e as EventArgs)

strQuery = "SELECT * from
mn_items,mn_records,mn_itemsStatus "
strQuery += "WHERE mid
='"&request.querystring("ItemId")&"' "
strQuery += "AND mn_items.parentrecord =
mn_records.recordid"
editDatalist.datasource = ExecuteQuery(strQuery)
editDatalist.databind()
editDatalist.datasource.close()

End Sub


</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:Table id="editTable" runat="server" GridLines="Both"
HorizontalAlign="Center" CellPadding="10">
<asp:TableRow>
<asp:TableCell>
<%# DataBinder.Eval(Container.DataItem, "itemid") %>
</asp:TableCell>
<asp:TableCell>
<input type="text" value='<%#
DataBinder.Eval(Container.DataItem, "Parentrecord") %>' />
</asp:TableCell>
<asp:TableCell>
<input type="text" value='<%#
DataBinder.Eval(Container.DataItem, "SearialNumber") %>' />
</asp:TableCell>
</asp:TableRow>
</asp:Table>


<table align="left">
<tbody>
<tr>
<th>ItemId</th>
<th>Parent record</th>
<th>Searial Number</th>
</tr>
<tr>
<td>
<input type="text" value='<%# DataBinder.Eval(Container.DataItem,
"itemid") %>' />
</td>
<td>
<input type="text" value='<%# DataBinder.Eval(Container.DataItem,
"Parentrecord") %>' />
</td>
<td>
<input type="text" value='<%# DataBinder.Eval(Container.DataItem,
"SearialNumber") %>' />
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
 
W

William Ryan eMVP

Rob:

What about a datagrid? Just set the datasource to your datatable and then
call DataGrid.DataBind
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top