Solved

Adding functionality to hyperlink on a DetailsView

Posted on 2008-10-14
7
549 Views
Last Modified: 2012-05-05
Hi all,

   I have a DetailView control on my page and have added a hyperlink that goes to another page.  Clicking on the link opens the other page fine, but I'd like to carry over information from the DetailView to the new page.  Not sure how to insert this code.  I was going to stuff the data into Session variables before the new page opened and then populate the new page with the Session data.  How do I do this?  Or is there a better way?  Thanks!
0
Comment
Question by:jvalescu
  • 4
  • 3
7 Comments
 
LVL 17

Accepted Solution

by:
NicksonKoh earned 500 total points
ID: 22717360
Hi there,

Session isn't a good way in this case. You can sent via query string.



    Dim strURL As String = "test.aspx"

    Dim arrParam(1) As String

    Dim strID, strName As String

    strID = "00123"

    strName = "Tester"

    

    arrParam(0) = "id=" & strID

    arrParam(1) = "name=" & strName

    strURL &= "?" & String.Join("&", arrParam)  'Just put strURl as the link

Open in new window

0
 

Author Comment

by:jvalescu
ID: 22717401
But where exactly do I put this code in the .cs file (I know your example is in VB, but I can translate it)?
0
 
LVL 17

Expert Comment

by:NicksonKoh
ID: 22717410

Show me your C# code and I'll tell you how to put it in.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:jvalescu
ID: 22717461
Here is the code behind.
using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Xml.Linq;
 

namespace IB

{

    public partial class SearchOrders : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            DetailsView1.Visible = false;

        }
 

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)

        {

            DetailsView1.Visible = true;

            DetailsView1.PageIndex = GridView1.SelectedIndex;

        }
 

        protected void FormView1_PageIndexChanging(object sender, FormViewPageEventArgs e)

        {
 

        }
 

        protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)

        {
 

        }
 

        protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)

        {

          //  GridView1.DataBind();

        }
 

        protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)

        {

            GridView1.DataBind();

            DetailsView1.Visible = false;
 

           

        }

    }

}

Open in new window

0
 

Author Comment

by:jvalescu
ID: 22717517
Not sure if you needed this to.
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"  

        CellPadding="4" DataSourceID="DetailsDataSource2" ForeColor="#333333" 

        GridLines="None" Height="50px" 

        style="z-index: 1; left: 1112px; top: 194px; position: absolute; height: 67px; width: 125px" 

        Width="125px" Caption="Edit Order" DataKeyNames="Control" 

        DefaultMode="Edit" Font-Size="Small" 

        onpageindexchanging="DetailsView1_PageIndexChanging" 

        onitemupdated="DetailsView1_ItemUpdated">

        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />

        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />

        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />

        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />

        <Fields>

            <asp:CommandField ShowEditButton="True" />

            <asp:HyperLinkField NavigateUrl="~/Allocation.aspx" Text="Allocate" />

            <asp:BoundField DataField="LineNumber" HeaderText="LineNumber" 

                SortExpression="LineNumber" ReadOnly="True" />

            <asp:BoundField DataField="RodSize" HeaderText="RodSize" 

                SortExpression="RodSize" />

            <asp:BoundField DataField="FinishedSize" HeaderText="FinishedSize" 

                SortExpression="FinishedSize" />

            <asp:BoundField DataField="Grade" HeaderText="Grade" 

                SortExpression="Grade" />

            <asp:BoundField DataField="Description" HeaderText="Description" 

                SortExpression="Description" />

            <asp:BoundField DataField="OrderQuantity" HeaderText="OrderQuantity" 

                SortExpression="OrderQuantity" />

            <asp:BoundField DataField="NoOfCoils" HeaderText="NoOfCoils" 

                SortExpression="NoOfCoils" />

            <asp:BoundField DataField="DueDate" HeaderText="DueDate" 

                SortExpression="DueDate" DataFormatString="{0:MMM-dd-yyyy}" 

                HtmlEncode="False" />

            <asp:BoundField DataField="PartNumber" HeaderText="PartNumber" 

                SortExpression="PartNumber" />

            <asp:BoundField DataField="PricePerCWT" HeaderText="PricePerCWT" 

                SortExpression="PricePerCWT" />

            <asp:BoundField DataField="Notes" HeaderText="Notes" 

                SortExpression="Notes" />

            <asp:BoundField DataField="Status" HeaderText="Status" 

                SortExpression="Status" />

            <asp:BoundField DataField="SecondaryRodSize" HeaderText="SecondaryRodSize" 

                SortExpression="SecondaryRodSize" />

            <asp:BoundField DataField="PrimaryDiameter" HeaderText="PrimaryDiameter" 

                SortExpression="PrimaryDiameter" />

            <asp:BoundField DataField="SecondaryDiameter" HeaderText="SecondaryDiameter" 

                SortExpression="SecondaryDiameter" />

            <asp:BoundField DataField="ShipDate" HeaderText="ShipDate" 

                SortExpression="ShipDate" DataFormatString="{0:MMM-dd-yyyy}" 

                HtmlEncode="False" />

            <asp:BoundField DataField="Process" HeaderText="Process" 

                SortExpression="Process" />

            <asp:BoundField DataField="PromisedDate" HeaderText="PromisedDate" 

                SortExpression="PromisedDate" DataFormatString="{0:MMM-dd-yyyy}" 

                HtmlEncode="False" />

            <asp:BoundField DataField="Control" HeaderText="Control" 

                SortExpression="Control" Visible="False" />

        </Fields>

        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

        <EditRowStyle BackColor="#999999" />

        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />

    </asp:DetailsView>

Open in new window

0
 
LVL 17

Expert Comment

by:NicksonKoh
ID: 22717616
Shruks, I just tried for a while and I am lost too as to how to edit the contents of a DetailView control! You need another expert.

For me, I personally just like to use only those simple HTML control and asked my development team to do likewise. They are much simpler to understand and control than those Datagrid, DetailView, etc!
0
 

Author Comment

by:jvalescu
ID: 22717834
I was messing with the _ItemCommand event and it fires if I hit the UPDATE or CANCEL buttons, but not on the Hyperlink fieldtype.  I saw the definition of the event as "Fires when any clickable element on the control is clicked. "   Anyone have any ideas?

protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e)

        {

            int i = 0;
 
 
 

        }

Open in new window

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now