Open GridView2 by selecting a GridView1 field

1

Hello. I am trying to make every time I select a specific field within GridView1 , it opens related data in an Access Database in GridView2 . This is the code for 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 populate 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 am using a Access database and to use GridView2 I use a second table.

For GridView1 I use the table " AllBatches " with the following columns: BatchID - Product - BatchSize - Priority / strong>

For GridView2 I want the table " IngredientsTable " to be called. It contains the following columns: Target - Minimum - Target - / strong> - WeighinhDate - Status - IDBatchID

In my Access database, the table works as I would like it to work in ASP.NET. When I click on the " BatchID " of the AllBatches "it opens a secondary table in the row below the row I clicked with the" IngredientsTable " . I created a relationship in the database between the two tables.

It may be too complex to do this, but I need help developing this functionality that at least opens

asked by anonymous 19.07.2017 / 15:58

0 answers