Hi Guys,
Can You Help Me PLease, I'm Currently facing Problems in my system...
I need some help...
I'm using VB script,ASP.net,MS SQL Server2005
I want to select a specific data in GridviewSummary, the specific data that I selected it will display the its details in GridviewDetails:
I have a 2 gridview the gridviewsummary and gridviewdetails:
gridviewsummary-contains Itemcode field(Primary key)
gridviewdetails-contains have Itemcode field(ForeignKey)
gridviewsummary-contains the summary of Items
gridviewdetails-contains the details of items
when I click one of the item in gridviewsummary, the details of that specific item will display its details in gridviewdetails.
Problem:
Passing the selected datakeyname is ok but the gridviewdetails was not displaying...
what should I do?
Here is the code:
-----------VB Code:-----------------------
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 intITPCodePK,strsubmitter,datRequested,datRequired FROM tblITPtransaction"
Dim myCommand As New SqlCommand(strSQL, con)
con.Open()
GVITPSumm.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConne ction)
GVITPSumm.DataBind()
End Sub
Sub GVITPSumm_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim con As New SqlConnection
con.ConnectionString = "Integrated Security=True;data source=ph-erwinm1;" & "persist security info=false;Initial Catalog=ITP"
Dim ITPCode As String
Dim strSQL As String
ITPCode = GVITPSumm.SelectedDataKey.Value.ToString()
strSQL = "SELECT intITPCodeFK, intItemCodePK, strItemType, intQuantity FROM tblItemList WHERE intITPCodeFK = '" & Trim$(ITPCode) & "'"
Dim myCommand As New SqlCommand(strSQL, con)
con.Open()
GVITPDetails.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConne ction)
GVITPDetails.DataBind()
End Sub
---------HTML Code -------------------
<asp:GridView style="LEFT: 2px; POSITION: relative; TOP: -33px" id="GVITPSumm"
runat="server" Width="606px" Height="18px" OnSelectedIndexChanged="GVITPSumm_SelectedIndexCha nged"
DataKeyNames="intITPCodePK" Font-Bold="False" EnableViewState="False" Font-Names="Arial"
Font-Overline="False" Font-Size="Smaller" AutoGenerateColumns="False" CellPadding="4"
AllowPaging="false" AllowSorting="True" ForeColor="#333333">
<FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True"></FooterStyle>
<Columns>
<asp:CommandField ShowSelectButton="True">
</asp:CommandField>
<asp:BoundField DataField="intITPCodePK" SortExpression="intITPCodePK" HeaderText="ITP 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>
<asp:GridView id="GVITPDetails" runat="server" AutoGenerateColumns="False" DataKeyNames="intITPCodeFK">
<Columns>
<asp:BoundField DataField="intITPCodeFK" SortExpression="intITPCodeFK" HeaderText="ITP Code"></asp:BoundField>
<asp:BoundField DataField="intItemCodePK" SortExpression="intItemCodePK" HeaderText="Item Code"></asp:BoundField>
<asp:BoundField DataField="strItemType" SortExpression="strItemType" HeaderText="Item Type"></asp:BoundField>
<asp:BoundField DataField="intQuantity" SortExpression="intQuantity" HeaderText="Quantity"></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>
Thank You in Advance