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>
</aspataGrid><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
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>
</aspataGrid><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