Master Detail ASP.net 2.0

Discussion in 'ASP .Net' started by Jon Paal, Nov 16, 2005.

  1. Jon Paal

    Jon Paal Guest

    need help trying to associate master/detail in ASP.net 2.0 with VWD2k5EE



    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    DetailsView1.DataItemIndex = GridView1.SelectedIndex '<-- need help with what goes here
    End Sub
     
    Jon Paal, Nov 16, 2005
    #1
    1. Advertising

  2. Jon Paal

    Joe Schmoe Guest

    No clue what is VWD2k5EE, but you'll probably need to access a record ID in
    a (hidden or viewable) column stored in the DataView to use for the Grid.
    Without knowing your table and how you are building your view, I can't give
    you an exact example. What data is in which column and in what format?

    "Jon Paal" <Jon nospam Paal @ everywhere dot com> wrote in message
    news:%...
    > need help trying to associate master/detail in ASP.net 2.0 with VWD2k5EE
    >
    >
    >
    > Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal
    > e As System.EventArgs)
    > DetailsView1.DataItemIndex = GridView1.SelectedIndex '<-- need help
    > with what goes here
    > End Sub
    >
     
    Joe Schmoe, Nov 16, 2005
    #2
    1. Advertising

  3. Jon Paal

    Jon Paal Guest

    VWD2k5EE =Visual Web Developer 2005 Express Edition

    This worked:


    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    DetailsView1.PageIndex = GridView1.SelectedIndex
    End Sub




    "Joe Schmoe" <> wrote in message news:2%Mef.11443$ih5.6681@dukeread11...
    > No clue what is VWD2k5EE, but you'll probably need to access a record ID in a (hidden or viewable) column stored in the DataView
    > to use for the Grid. Without knowing your table and how you are building your view, I can't give you an exact example. What data
    > is in which column and in what format?
    >
    > "Jon Paal" <Jon nospam Paal @ everywhere dot com> wrote in message news:%...
    >> need help trying to associate master/detail in ASP.net 2.0 with VWD2k5EE
    >>
    >>
    >>
    >> Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    >> DetailsView1.DataItemIndex = GridView1.SelectedIndex '<-- need help with what goes here
    >> End Sub
    >>

    >
    >
     
    Jon Paal, Nov 16, 2005
    #3
  4. Jon Paal

    Joe Schmoe Guest

    OK, isn't that the same thing you had originally. Glad it works. *confused*

    "Jon Paal" <Jon nospam Paal @ everywhere dot com> wrote in message
    news:...
    > VWD2k5EE =Visual Web Developer 2005 Express Edition
    >
    > This worked:
    >
    >
    > Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal
    > e As System.EventArgs)
    > DetailsView1.PageIndex = GridView1.SelectedIndex
    > End Sub
    >
    >
    >
    >
    > "Joe Schmoe" <> wrote in message
    > news:2%Mef.11443$ih5.6681@dukeread11...
    >> No clue what is VWD2k5EE, but you'll probably need to access a record ID
    >> in a (hidden or viewable) column stored in the DataView to use for the
    >> Grid. Without knowing your table and how you are building your view, I
    >> can't give you an exact example. What data is in which column and in what
    >> format?
    >>
    >> "Jon Paal" <Jon nospam Paal @ everywhere dot com> wrote in message
    >> news:%...
    >>> need help trying to associate master/detail in ASP.net 2.0 with
    >>> VWD2k5EE
    >>>
    >>>
    >>>
    >>> Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object,
    >>> ByVal e As System.EventArgs)
    >>> DetailsView1.DataItemIndex = GridView1.SelectedIndex '<-- need help
    >>> with what goes here
    >>> End Sub
    >>>

    >>
    >>

    >
    >
     
    Joe Schmoe, Nov 16, 2005
    #4
  5. Jon Paal

    Jon Paal Guest

    no, I changed the code.

    found another problem though, the master, when paged , doesn't send correct index to detail

    How do I get the code to reflect correct master index with paging enabled ?


    [full code to northwind database customers table]

    <%@ Page Language="VB" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    DetailsView1.PageIndex = GridView1.SelectedIndex
    End Sub
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    &nbsp;</div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
    Style="z-index: 100; left: 85px; position: absolute; top: 154px" AllowPaging="True" BackColor="LightGoldenrodYellow"
    BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None" Width="231px">
    <Columns>
    <asp:CommandField ShowSelectButton="True" />
    <asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
    ReadOnly="True" SortExpression="ProductID" />
    <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
    </Columns>
    <PagerSettings FirstPageText="First" LastPageText="Last" Mode="NextPrevious" NextPageText="Next"
    PreviousPageText="Prev" />
    <FooterStyle BackColor="Tan" />
    <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
    <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
    <HeaderStyle BackColor="Tan" Font-Bold="True" />
    <AlternatingRowStyle BackColor="PaleGoldenrod" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindCSConnectionString %>"
    SelectCommand="SELECT * FROM [Alphabetical List of Products]">
    </asp:SqlDataSource>
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
    DataSourceID="SqlDataSource1" Height="50px" Style="z-index: 102; left: 386px;
    position: absolute; top: 160px" Width="270px">
    <Fields>
    <asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
    ReadOnly="True" SortExpression="ProductID" />
    <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
    <asp:BoundField DataField="SupplierID" HeaderText="SupplierID" SortExpression="SupplierID" />
    <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID" />
    <asp:BoundField DataField="QuantityPerUnit" HeaderText="QuantityPerUnit" SortExpression="QuantityPerUnit" />
    <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
    <asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" />
    <asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder" />
    <asp:BoundField DataField="ReorderLevel" HeaderText="ReorderLevel" SortExpression="ReorderLevel" />
    <asp:BoundField DataField="Discontinued" HeaderText="Discontinued" SortExpression="Discontinued" />
    <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
    </Fields>
    </asp:DetailsView>
    </form>
    </body>
    </html>
     
    Jon Paal, Nov 16, 2005
    #5
    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. Swati
    Replies:
    1
    Views:
    610
    Cowboy \(Gregory A. Beamer\) [MVP]
    Jul 13, 2004
  2. A.C van Bers

    ASP.Net 2.0 Master-Detail

    A.C van Bers, Aug 9, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    525
    A.C van Bers
    Aug 9, 2004
  3. asmj
    Replies:
    0
    Views:
    511
  4. Arun Kumar Menon

    Master Detail detail

    Arun Kumar Menon, Aug 6, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    207
    Arun Kumar Menon
    Aug 6, 2003
  5. Frederik Borg

    ASp.net data binding: Master-detail-detail

    Frederik Borg, Jun 9, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    365
    Frederik Borg
    Jun 9, 2006
Loading...

Share This Page