Jeg skal overføre et id nummer mellem 2 GridView, der er i hver sin user control. Hvordan gør jeg det?
Jeg har lavet det hele på en side og det virker fint (se nedenstående kode). Men hvordan deler jeg det om, så jeg kan overføre id nummer fra GridView1 til Gridview2, når de ligger i hver sin user control?
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" BackColor="White" BorderColor="#E7E7FF"
BorderStyle="None" BorderWidth="0px" CellPadding="3" GridLines="None"
DataKeyNames="id" ShowHeader="False">
<RowStyle BackColor="#6699CC" ForeColor="#FFFFFF" HorizontalAlign="Left" />
<Columns>
<asp:ButtonField DataTextField="knap" CommandName="Select" SortExpression="knap" ButtonType="Link" />
</Columns>
<SelectedRowStyle BackColor="#738A9C" ForeColor="#F7F7F7" />
<HeaderStyle BackColor="#6699CC" Font-Bold="True" ForeColor="#F7F7F7" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [id], [knap], [prioritet] FROM [hovedknapper] ORDER BY [prioritet]">
</asp:SqlDataSource>
<h3>Undermenu</h3>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
DataKeyNames="umID" DataSourceID="Sqlundermenu" BackColor="White" BorderColor="#E7E7FF"
BorderStyle="None" BorderWidth="0px" CellPadding="3" GridLines="None">
<RowStyle BackColor="#6699CC" ForeColor="#FFFFFF" HorizontalAlign="Left" />
<Columns>
<asp:ButtonField DataTextField="umKnap" CommandName="Select" SortExpression="umKnap" />
</Columns>
<SelectedRowStyle BackColor="#738A9C" ForeColor="#F7F7F7" />
<HeaderStyle BackColor="#6699CC" Font-Bold="True" ForeColor="#F7F7F7" />
</asp:GridView>
<asp:SqlDataSource ID="Sqlundermenu" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [umID], [hkID], [umKnap] FROM [UnderMenu] WHERE ([hkID] = @hkID2)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" DefaultValue="2" Name="hkID2"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>