I'm not sure how you're binding your Gridviews behind the scenes, or what your architechture is. Could you post some source code?
Here's one way in which this could be done (in C#), assuming that your UI relies on the underlying business objects to deliver data ,
aspx
<!-- item gridview -->
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="GridView1_SelectedIndexCha nged" DataKeyNames="PrimaryKeyName">
<Columns>
<!-- this is the select hyperlink for each row -->
<asp:CommandField ShowSelectButton="True">
</asp:CommandField>
</asp:GridView>
<!-- Details Gridview -->
<asp:GridView ID="GridView2" runat="server">
</asp:GridView>
aspx.cs
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
//assuming that itemcode is a unique int
int itemCode = Convert.ToInt32(GridView1.SelectedDataKey.Value.To String());
//assuming that the Details of every item might be contained in a different
// business object which constructs itself based on the item code;
// you might not be following an n-tiered approach, in which case
// you could commands to get the data directly
ItemDetails details = new ItemDetails(itemCode);
GridView2.DataSource = details;
GridView2.DataBind();
}
Can You write it in vb script?please...Thank You
I'm Using ASP.net and MS SQL2005 and I'm using VB SCRIPT
Here is my code:
Code: ( vbnet )
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim con As New SqlConnection
con.ConnectionString = "Integrated Security=True;data source=ph-erwinm1;" & "persist security info=false;Initial Catalog=ITP"
Const strSQL As String = "SELECT intItemCodePK,strsubmitter,datRequested,datRequire d FROM tblITPtransaction"
Dim myCommand As New SqlCommand(strSQL, con)
con.Open()
GridItemcodeSumm.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConne ction)
GridItemcodeSumm.DataBind()
end sub
----------HTML-------------
<asp:GridView id="GridItemcodeSumm" runat="server" Width="606px" Height="18px" ForeColor="#333333" AllowSorting="True" AllowPaging="false" CellPadding="4" AutoGenerateColumns="False" Font-Size="Smaller" Font-Overline="False" Font-Names="Arial" EnableViewState="False" Font-Bold="False" style="left: 2px; position: relative; top: -33px">
<FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True"></FooterStyle>
<Columns>
<asp:BoundField DataField="intItemCodePK" SortExpression="intItemCodePK" HeaderText="Item Code"></asp:BoundField>
<asp:BoundField DataField="strsubmitter" SortExpression="strsubmitter" HeaderText="Submitter"></asp:BoundField>
<asp:BoundField DataField="datRequested" SortExpression="datRequested" HeaderText="Date Requested"></asp:BoundField>
<asp:BoundField DataField="datRequired" SortExpression="datRequired" HeaderText="Date Required"></asp:BoundField>
</Columns>
<RowStyle BackColor="#EFF3FB"></RowStyle>
<EditRowStyle BackColor="#2461BF"></EditRowStyle>
<SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True"></SelectedRowStyle>
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center"></PagerStyle>
<HeaderStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True"></HeaderStyle>
<AlternatingRowStyle BackColor="White"></AlternatingRowStyle>
</asp:GridView>
I'm Using ASP.net and MS SQL2005 and I'm using VB SCRIPT
Here is my code:
Code: ( vbnet )
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim con As New SqlConnection
con.ConnectionString = "Integrated Security=True;data source=ph-erwinm1;" & "persist security info=false;Initial Catalog=ITP"
Const strSQL As String = "SELECT intItemCodePK,strsubmitter,datRequested,datRequire d FROM tblITPtransaction"
Dim myCommand As New SqlCommand(strSQL, con)
con.Open()
GridITPSumm.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConne ction)
GridITPSumm.DataBind()
end sub
----------HTML-------------
<asp:GridView id="GridItemcodeSumm" runat="server" Width="606px" Height="18px" ForeColor="#333333" AllowSorting="True" AllowPaging="false" CellPadding="4" AutoGenerateColumns="False" Font-Size="Smaller" Font-Overline="False" Font-Names="Arial" EnableViewState="False" Font-Bold="False" style="left: 2px; position: relative; top: -33px">
<FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True"></FooterStyle>
<Columns>
<asp:BoundField DataField="intItemCodePK" SortExpression="intItemCodePK" HeaderText="Item Code"></asp:BoundField>
<asp:BoundField DataField="strsubmitter" SortExpression="strsubmitter" HeaderText="Submitter"></asp:BoundField>
<asp:BoundField DataField="datRequested" SortExpression="datRequested" HeaderText="Date Requested"></asp:BoundField>
<asp:BoundField DataField="datRequired" SortExpression="datRequired" HeaderText="Date Required"></asp:BoundField>
</Columns>
<RowStyle BackColor="#EFF3FB"></RowStyle>
<EditRowStyle BackColor="#2461BF"></EditRowStyle>
<SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True"></SelectedRowStyle>
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center"></PagerStyle>
<HeaderStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True"></HeaderStyle>
<AlternatingRowStyle BackColor="White"></AlternatingRowStyle>
</asp:GridView>