Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Best advice needed navigation/display through dataset on one page

Reply
Thread Tools

Best advice needed navigation/display through dataset on one page

 
 
janetb
Guest
Posts: n/a
 
      05-05-2006
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).it em(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(varBk m)).Item(3)) %><br />
page image: <%
'response.write(ds.Tables("pages").Rows(CInt(varBk m)).Item(4)) %><br />
page content: <%
'response.write(ds.Tables("pages").Rows(CInt(varBk m)).Item(5)) %><br />
</form>
<html>
<body

 
Reply With Quote
 
 
 
 
janetb
Guest
Posts: n/a
 
      05-09-2006
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


"janetb" wrote:

> 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).it em(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(varBk m)).Item(3)) %><br />
> page image: <%
> 'response.write(ds.Tables("pages").Rows(CInt(varBk m)).Item(4)) %><br />
> page content: <%
> 'response.write(ds.Tables("pages").Rows(CInt(varBk m)).Item(5)) %><br />
> </form>
> <html>
> <body
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advice needed: Best way to deploy/manage SQL db website Bobby Edward ASP .Net 7 02-22-2008 02:37 PM
Advice Needed: Best way to use Maven (w. Eclipse/Struts/Spring/Hibernate/svn/ant) etienno Java 0 12-13-2006 10:15 AM
Page through dataset w/o postback. Shawn Repphan ASP .Net 4 11-01-2005 02:14 PM
Re: Advice needed: Best photo editor? ameyer2@yahoo.com Digital Photography 2 01-04-2005 01:22 AM
Needed: Advice on Film Scanning, Or Website Which Has This Advice Larry R Harrison Jr Digital Photography 0 09-06-2003 01:00 AM



Advertisments