Best advice needed navigation/display through dataset on one page

J

janetb

I'm trying to create a page that has a menu down the left side with one field
within the dataset displaying, but clickable. OnClick, I'd like to have
items displayed to the right (since one field is a pointer to an image, is it
better to response.write or use a label?). I've tried using a datagrid with
a dataset, but the buttonColumn doesn't let you dictate the text display from
an item in the dataset? And, I can't get it to reflect to the right. I'd
apprciate any advice. I'm giving it a shot, but I'm not getting very far.


<%@ 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, varWID as integer, varPID 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 w_ID as New SqlParameter("@ID",varWid)
da.SelectCommand.Parameters.Add(w_ID)
da.Fill(ds, "pages")
dgNavList.DataSource=ds.tables("pages")
dgNavList.DataBind()
End Sub

Sub chgPage(Sender As Object, E As DataGridCommandEventArgs)
varBkm=e.Item.ItemIndex
txtBkm.text=varBkm
lblPgTitle.text=ds.tables("pages").rows(varBkm).item(2)
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
response.redirect("login.asp")
else
varWid=request("wid")
varPid=request("pid")
txtPID.text=varPid
txtWID.text=varWid
if request("bkm")="" then varBkm=0 else varBkm=cint(request("bkm"))
txtBkm.text=varBkm
end if
bindNav()
End If
end sub

</script>

<form id="Form1" method="post" runat="server">
<asp:datagrid id="dgNavList" onEditCommand="chgPage"
autogenerateColumns="False" runat="server">
<Columns>
<asp:BoundColumn DataField="pageID_pk" Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="pgTitle" Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="pgDesc" Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="navTitle"></asp:BoundColumn>
<asp:ButtonColumn Text="Edit" CommandName="Edit" />
</Columns>
</asp:DataGrid><br />
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" /><br />

page title: <asp:label id="lblPgTitle" runat="server" />

<% '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 />
</form>
<html>
<body
 
J

janetb

Have everything now working except one thing. I'm making first, last, next,
prev buttons that are outside of the datagrid. The labels/buttons that are
assigned value/commands respectively based on which row of the datagrid is
selected. Then, if the button outside the datagrid is pushed, I want it to
go to the correct row of the datagrid and display a hidden cell of the
datagrid in a label field. What is the correct syntax for pulling a
datagrid's hidden column based on a button click outside of the datagrid? If
you look at the code below, the correct row in the datagrid is highlighted
when I push the next button, but I can't get the syntax right to have the
lblPgTitle display the hidden cell of the datagrid. (datagrid cell
specifically is DataField="pgTitle")

sub pgNext(sender as object, e as eventArgs)
dim n as integer=cint(lblNext.text)
dgNavList.selectedIndex=n
lblPgTitle.text=dgNavList.item.cells(1).text
end sub

Many thanks for any help.... Janet
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top