Here is my problem...

I am developing a portion of my website to sell my floor plans online. I have an access database linked to a Datalist that displays a thumbnail elevation and some basic info about that plan. What I am having problems with is once a person clicks a thumbnail elevation that they like I want it to pop up on another page with a larger elevation image, the actual floor plan and all the detailed information about the plan, which is all stored in the same database. How do I pass that one entry in the database to carry over to another page and display. I know I am probably making this a lot harder then it actaully is!

I am using Expression Web 2 and Visual Web Studio Express.

Any help would be greatly appreciated!

Recommended Answers

All 9 Replies

That would depend upon if you have a unique value representing the thumbnail elevation in question.

What you could do is , on the selection of the thumbnail pass this unique value as a query string or a session variable to the pop-up page and let the page load event retrieve the rest of the info for you to be rendered on this page.

I hope this is what you need.
Let me know in case of any doubts.

I may have undertaken a task that is far beyond my programming ability but I think I am going in the right direction now. I am still having some problems with the logic (Which I feel like I am out of).
1. I create a script for the "Button_Click" in "planlist.aspx"

Sub Plan_Click(ByVal Sender As Object, ByVal e As EventArgs)
         Session("DataListCopy") = Datalist1.???  \\ Not sure what to use here to copy the whole datalist.            
End Sub
  1. Then when I post it to the next page "plandetail.aspx"

    sub Page_Load(obj as object, e as eventArgs)
    \How do I tell the Formview to use that session?

Any help or direction would be very helpful.

Member Avatar for rajarajan2017

Hi,

I think u can use the query string to pass values from one page to another page. Please look into the coding below as an example and you implement this in your situation, it will work.

Here we having a listbox and a checkbox (to select mode)

Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
        ' Add sample values.
        lstItems.Items.Add("Econo Sofa")
        lstItems.Items.Add("Supreme Leather Drapery")
        lstItems.Items.Add("Threadbare Carpet")
        lstItems.Items.Add("Antique Lamp")
        lstItems.Items.Add("Retro-Finish Jacuzzi")
    End Sub

    Private Sub cmdGo_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdGo.Click
            Dim Url As String = "QueryStringRecipient.aspx?"
            Url &= "Item=" & lstItems.SelectedItem.Text & "&"
            Url &= "Mode=" & chkDetails.Checked.ToString()
            Response.Redirect(Url)
        End If
    End Sub

QueryStringReceipient.aspx

Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
        lblInfo.Text = "Item: " & Request.QueryString("Item") & "<br>"
        lblInfo.Text &= "Show Full Record: " & Request.QueryString("Mode")
End Sub

Sure it will work and If it works add to my reputation and mark it as solved.

Your code above helped. Thanks. But now I have a new problem. When my Image Button calls my subroutine "PlanClick" it says that PlanClick is not defined. Why? Am I missing something here? Again, Any help is appreciated!

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="Server" type="text/VB">
    Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs)
        Label1.Text = "This Works"
    End Sub
</script>

<script runat="server" type="text/VB">
    Public Sub PlanClick(ByVal obj As Object, ByVal e As EventArgs)
        Response.Redirect("http://www.MyTargetPage.com")
    End Sub
</script>    


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Floor Plan Lists</title>
</head>

<body>
    <form id="form1" method="post" runat="server" >
    <div>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:Button ID="Button1" runat="server" Text="Button" EnableTheming="False" OnClientClick="PlanClick" />
        <asp:DataList ID="DataList1" runat="server" DataKeyField="ID1" DataSourceID="AccessDataSource1"
            RepeatColumns="2" RepeatDirection="Horizontal">
            <ItemTemplate>
                <asp:ImageButton ID="ImageButton1" runat="server" Height="135px" ImageUrl='<%# Eval("FrontElev_TN") %>' Width="180px" OnClientClick="Submit_Click" /><br />
                ID1:
                <asp:Label ID="ID1Label" runat="server" Text='<%# Eval("ID1") %>'></asp:Label><br />
                PlanNumber:
                <asp:Label ID="PlanNumberLabel" runat="server" Text='<%# Eval("PlanNumber") %>'></asp:Label><br />
            </ItemTemplate>
        </asp:DataList><asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/Plans/floorplans.mdb"
            SelectCommand="SELECT * FROM [tblFPInfo]"></asp:AccessDataSource>
    
    </div>
    </form>
</body>
</html>

I accidently was calling the wrong sub name but even after I fixed it I still get the same error message. Error: 'Submit_Click" is not defined. I know it is! What am I doing wrong?

Member Avatar for rajarajan2017

In above coding itself, submit_click was missed up. Please check it.

hi ,
if u r using datalist the child control events will not raised directly.so use itemcommand(bubble event) of datalist to raise image button click event.
below is the eg iam giving hope this will help u....

<asp:DataList ID="DataList1" runat="server" OnItemCommand="DataList1_ItemCommand">
        <ItemTemplate>
            <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/progressAnimation.gif" CommandArgument ="uniquecolumn" CommandName ="navigate" />
        </ItemTemplate>
        </asp:DataList>

protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName = "navigate")
        {
            string uniquekey = e.CommandArgument.ToString();
            //do something if u want
            Response.Redirect("~/somepage.aspx?uk=" + uniquekey);
        }
    }

I appreciate everyones help so far!!! It still isn't not working though. I don't know why it won't call the script from the "OnClientClick". Any help? Anyone? Code Below...

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="Server" type="text/VB">
    Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs)
        Label1.Text = "This WOrks"
    End Sub
</script>

<script runat="Server" type="text/VB"> ' Script to redirect and post to querystring
    Sub DataList1_ItemCommand(ByVal source As Object, ByVal e As DataListCommandEventArgs) Handles DataList1.ItemCommand
        If (e.CommandName = "Navigate") Then
            Response.Redirect("plandetail.aspx")
        End If
    End Sub
</script>


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>

<body>
    <form id="form1" method="post" runat="server" >
    <div>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:Button ID="Button1" runat="server" Text="Button" EnableTheming="False" OnClientClick="DataList1_ItemCommand" />
        <asp:DataList ID="DataList1" runat="server" DataKeyField="ID1" DataSourceID="AccessDataSource1"
            RepeatColumns="2" RepeatDirection="Horizontal">
            <ItemTemplate>
                <asp:ImageButton ID="ImageButton1" runat="server" Height="135px" ImageUrl='<%# Eval("FrontElev_TN") %>' Width="180px" OnClientClick="DataList1_ItemCommand" CommandArgument="PlanNumber" CommandName="navigate" /><br />
                ID1:
                <asp:Label ID="ID1Label" runat="server" Text='<%# Eval("ID1") %>'></asp:Label><br />
                PlanNumber:
                <asp:Label ID="PlanNumberLabel" runat="server" Text='<%# Eval("PlanNumber") %>'></asp:Label><br />
            </ItemTemplate>
        </asp:DataList><asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/Plans/floorplans.mdb"
            SelectCommand="SELECT * FROM [tblFPInfo]"></asp:AccessDataSource>
    
    </div>
    </form>
</body>
</html>

hi,

<asp:ImageButton ID="ImageButton1" runat="server" Height="135px" ImageUrl='<%# Eval("FrontElev_TN") %>' Width="180px" OnClientClick="DataList1_ItemCommand" CommandArgument="PlanNumber" CommandName="navigate" /><

in this emove on client click it will not work.(i already told u that child control events will not raise)...so use comand name.in server side if command name is navigate means the imgbutton clicked.so do what ever u want..if have any other button or link button then set another command name.to catch that control event.
hope u understood.......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.