Datagrid button

Discussion in 'ASP .Net' started by brock wade, Jun 11, 2008.

  1. brock wade

    brock wade Guest

    I have a Datagrid that is working fine displying my records, but I'm
    trying to program buttons
    on each record line to launch another web page that shows all the
    details for the product:

    <asp:datagrid id="dgProducts" runat="server">
    <asp:ButtonColumn Text="Details" CommandName="Details"
    ButtonType="PushButton"></asp:ButtonColumn>
    </asp:datagrid>


    Should I go to my code-behind to do something like this?:


    Sub detailsClicked(ByVal sender As Object, ByVal e As
    DataGridCommandEventArgs)
    Response.Redirect("www.mysite.com\details.aspx")
    End Sub


    If so how can I pass the chosen record's key information into the new
    page to pickup the details?
     
    brock wade, Jun 11, 2008
    #1
    1. Advertising

  2. brock wade

    Munna Guest

    On Jun 12, 12:42 am, brock wade <> wrote:
    > I have a Datagrid that is working fine displying my records, but I'm
    > trying to program buttons
    > on each record line to launch another web page that shows all the
    > details for the product:
    >
    > <asp:datagrid id="dgProducts" runat="server">
    > <asp:ButtonColumn Text="Details" CommandName="Details"
    > ButtonType="PushButton"></asp:ButtonColumn>
    > </asp:datagrid>
    >
    > Should I go to my code-behind to do something like this?:
    >
    > Sub detailsClicked(ByVal sender As Object, ByVal e As
    > DataGridCommandEventArgs)
    > Response.Redirect("www.mysite.com\details.aspx")
    > End Sub
    >
    > If so how can I pass the chosen record's key information into the new
    > page to pickup the details?


    Hi

    You are taking about master detail view of course.
    check out this tutorial... i believe this is what you want...
    http://www.asp.net/learn/data-access/tutorial-10-vb.aspx

    Best of luck

    Munna
    www.munna.shatkotha.com
    www.munna.shatkotha.com/blog
    www.shatkotha.com
     
    Munna, Jun 12, 2008
    #2
    1. Advertising

  3. brock wade

    brock wade Guest

    Thanks for the link. It looks good. Let me make sure I'm on the
    correct path here. I have a DataGrid and the only change I've made so
    far is adding "DataTextField="Key"

    <asp:datagrid id="dgProducts" runat="server">
    <asp:ButtonColumn Text="Details" CommandName="Details"
    DataTextField="Key"
    ButtonType="PushButton"></asp:ButtonColumn>
    </asp:datagrid>

    The reason I used "Key" is the way the code-behind ia setup (note the
    dr.Key):

    Private Sub SetListViewItem(ByVal dr As Employee, ByVal dt As
    DataTable, ByVal count As Integer)
    If count = 0 Then
    dt.Columns.Add("Emp #")
    dt.Columns.Add("Last Name")
    dt.Columns.Add("First Name")
    dt.Columns.Add("Title")
    End If
    Dim EmpPos As Action = (New
    ActionBroker).GetActionCurrent(dr.Key, Today, Global.UserName,
    Global.UserPassword, Global.appDataSource)
    Dim employee As DataRow = dt.NewRow
    employee("Emp #") = dr.Key
    employee("Last Name") = dr.LastName
    employee("First Name") = dr.FirstName
    employee("Title") = EmpPos.WorkAgainstInfo.Title
    dt.Rows.Add(employee)
    End Sub 'SetListViewItem

    When I run the page though it says that "A field or property with the
    name 'Key' was not found on the selected datasource."

    Any ideas?




    On Jun 12, 4:23 am, Munna <> wrote:
    > On Jun 12, 12:42 am, brock wade <> wrote:
    >
    >
    >
    >
    >
    > > I have a Datagrid that is working fine displying my records, but I'm
    > > trying to program buttons
    > > on each record line to launch another web page that shows all the
    > > details for the product:

    >
    > > <asp:datagrid id="dgProducts" runat="server">
    > >         <asp:ButtonColumn Text="Details" CommandName="Details"
    > > ButtonType="PushButton"></asp:ButtonColumn>
    > >         </asp:datagrid>

    >
    > > Should I go to my code-behind to do something like this?:

    >
    > >     Sub detailsClicked(ByVal sender As Object, ByVal e As
    > > DataGridCommandEventArgs)
    > >         Response.Redirect("www.mysite.com\details.aspx")
    > >     End Sub

    >
    > > If so how can I pass the chosen record's key information into the new
    > > page to pickup the details?

    >
    > Hi
    >
    > You are taking about master detail view of course.
    > check out this tutorial... i believe this is what you want...http://www.asp.net/learn/data-access/tutorial-10-vb.aspx
    >
    > Best of luck
    >
    > Munnawww.munna.shatkotha.comwww.munna.shatkotha.com/blogwww.shatkotha.com- Hide quoted text -
    >
    > - Show quoted text -
     
    brock wade, Jun 12, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Purvi T
    Replies:
    0
    Views:
    857
    Purvi T
    Oct 19, 2004
  2. Wes Weems
    Replies:
    1
    Views:
    485
    Natty Gur
    Jul 20, 2003
  3. Chris Lane
    Replies:
    4
    Views:
    11,238
    Chris Lane
    Nov 17, 2003
  4. jorge
    Replies:
    2
    Views:
    1,274
    jorge
    May 26, 2004
  5. Andreas Klemt
    Replies:
    0
    Views:
    309
    Andreas Klemt
    Oct 8, 2003
Loading...

Share This Page