Open Gridview2 by selecting a Gridview1 field

Asked

Viewed 35 times

1

Hello. I’m trying to get every time I select a specific field within the Gridview1, open related data in an Access Database on Gridview2. That’s the code on my page.

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="MainView.aspx.vb" Inherits="DosimetryASPNET_WebApplication.MainView" %>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
</asp:Content>


<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
    <asp:Button ID="btnMenuView" runat="server" Text="Return to Menu" Width="200px" OnClick="btnMenuView_Click" />
    <br />
    <br />

</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder4" runat="server">
    <br />
    <br />

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="BatchID" >
        <Columns>
            <asp:BoundField DataField="BatchID" HeaderText="BatchID" InsertVisible="False" ReadOnly="True" SortExpression="BatchID" />
            <asp:BoundField DataField="Product" HeaderText="Product" SortExpression="Product" />
            <asp:BoundField DataField="BatchSize" HeaderText="BatchSize" SortExpression="BatchSize" />
            <asp:BoundField DataField="Priority" HeaderText="Priority" SortExpression="Priority" />
            <asp:BoundField DataField="StartReq" HeaderText="StartReq" SortExpression="StartReq" />
            <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
        </Columns>
    </asp:GridView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString1 %>" ProviderName="<%$ ConnectionStrings:NorthwindConnectionString1.ProviderName %>" SelectCommand="SELECT * FROM [AllBatches]"></asp:SqlDataSource>

    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="BatchID" Visible="False">
    </asp:GridView>

</asp:Content>  

This is the code I use to popular the Gridview1

Private Sub GridView1_LoadData(sender As Object, e As EventArgs) Handles Me.Load
        Dim dt As New Northwind.AllBatchesDataTable
        Using da As New NorthwindTableAdapters.AllBatchesTableAdapter
            da.Fill(dt)
        End Using
            GridView1.DataSource = dt.DefaultView
            GridView1.DataBind()
End Sub  

I’m using a database Access and to popular the Gridview2 I use a second table.

To the Gridview1 use the table "Allbatches" with the following columns: Batchid - Product - Batchsize - Priority - Startreq - Status

To the Gridview2 I want the table "Ingredientstable" is called. It contains the following columns: Lotmanufactid - Ingredient - Current - Target - Minimum - Maximum - Weighinhdate - Status - Idbatchid

In my bank Access, The table works as I would like it to work in ASP.NET. When I click on "Batchid" of "Allbatches" it opens a secondary table in the row below the row I clicked with the data from "Ingredientstable". I created a database relationship between the two tables.

It may be too complex to do this way, but I need help to develop this feature that at least opens on Gridview2 the data of "Ingredientstable" related to the "Batchid" of "Allbatches".

I hope you were able to illustrate my doubt and be clear. I’m waiting for help.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.