View Full Version : Advice needed - dg/repeater/response.write

05-04-2006, 11:49 PM
Trying to determine best method of displaying a navigation of one field down left-hand side of page as a navigation, and then displaying some fields of one record at a time on the page.

I can populate the dataset, but then wondered about the navigation on the left? Thought buttonColumns would be best, but need to be able to dynamically populate the text. That way, if I have the navigation that would make sense to a user, but only make the trip to the server once, and then use the event handler to select the rowIndex? Upon displaying the page, because they're some image (pointer) fields and large text blocks, I'd rather just right them out in old-fashioned reponse.write code.

Here's what I've got which doesn't work (dataset is fine, rest is pretty much hosed). Any pointers?

<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Data" %>
<%@Page Language="VB" debug="True"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<script language="vb" runat="server">
Public strConn As String = "connection string stuff;"
Public cn As New SqlClient.SqlConnection(strConn)
Public cmd as sqlclient.sqlCommand
Public ds as New Dataset
Public varBkm as integer

Sub bindNav()
Dim ds as New Dataset
Dim da as New SQLDataAdapter
da = New SqlDataAdapter("sp_eCoursePage", cn)
da.SelectCommand.CommandType = CommandType.StoredProcedure
Dim p_ID as New SqlParameter("@ID",txtWID.text)
da.Fill(ds, "pages")
End Sub

sub chgPage(sender As Object, e As System.EventArgs)
end sub
Sub Page_load(sender as Object, e as EventArgs)
If Not (IsPostBack)
if request("pid")="" or request("pid")="0" or request("wid")="" or request("wid")="0" then
if request("bkm")="" then varBkm=0 else varBkm=cint(request("bkm"))
end if
'put in code to change varBkm when page changes.
End If
end sub

<body><form id="Form1" method="post" runat="server">
<asp:datagrid id="dgNavList" autogenerateColumns="False" runat="server">
<asp:BoundColumn DataField="pageID_pk" Visible="False"></asp:BoundColumn>
<asp:buttonColumn text="<%= ds.Tables("pages").item(6) %>" CommandName="Edit" />
pid: <asp:label id="txtPID" runat="server" visible="true" /><br />
wid: <asp:label id="txtWID" runat="server" visible="true" /><br />
bkm: <asp:label id="txtBkm" runat="server" visible="true" /><br />
<asp:Button id="btnChange" runat="server" Text="Update" onClick="chgPage" /><br />
page title: <% 'response.write(ds.Tables("pages").Rows(CInt(varBkm)).Item(3)) %><br />
page image: <% 'response.write(ds.Tables("pages").Rows(CInt(varBkm)).Item(4)) %><br />
page content: <% 'response.write(ds.Tables("pages").Rows(CInt(varBkm)).Item(5)) %><br />