VB SCRIPT - Problem in Selecting data in Gridview Control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaredciagar
    New Member
    • Feb 2008
    • 16

    VB SCRIPT - Problem in Selecting data in Gridview Control

    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(ForeignKe y)

    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.EventArg s)

    Dim con As New SqlConnection


    con.ConnectionS tring = "Integrated Security=True;d ata source=ph-erwinm1;" & "persist security info=false;Init ial Catalog=ITP"

    Const strSQL As String = "SELECT intITPCodePK,st rsubmitter,datR equested,datReq uired FROM tblITPtransacti on"
    Dim myCommand As New SqlCommand(strS QL, con)

    con.Open()
    GVITPSumm.DataS ource = myCommand.Execu teReader(Comman dBehavior.Close Conne ction)
    GVITPSumm.DataB ind()
    End Sub


    Sub GVITPSumm_Selec tedIndexChanged (ByVal sender As Object, ByVal e As EventArgs)
    Dim con As New SqlConnection

    con.ConnectionS tring = "Integrated Security=True;d ata source=ph-erwinm1;" & "persist security info=false;Init ial Catalog=ITP"

    Dim ITPCode As String
    Dim strSQL As String
    ITPCode = GVITPSumm.Selec tedDataKey.Valu e.ToString()

    strSQL = "SELECT intITPCodeFK, intItemCodePK, strItemType, intQuantity FROM tblItemList WHERE intITPCodeFK = '" & Trim$(ITPCode) & "'"

    Dim myCommand As New SqlCommand(strS QL, con)
    con.Open()
    GVITPDetails.Da taSource = myCommand.Execu teReader(Comman dBehavior.Close Conne ction)
    GVITPDetails.Da taBind()

    End Sub




    ---------HTML Code -------------------

    <asp:GridView style="LEFT: 2px; POSITION: relative; TOP: -33px" id="GVITPSumm"
    runat="server" Width="606px" Height="18px" OnSelectedIndex Changed="GVITPS umm_SelectedInd exChanged"
    DataKeyNames="i ntITPCodePK" Font-Bold="False" EnableViewState ="False" Font-Names="Arial"
    Font-Overline="False " Font-Size="Smaller" AutoGenerateCol umns="False" CellPadding="4"
    AllowPaging="fa lse" AllowSorting="T rue" ForeColor="#333 333">
    <FooterStyle BackColor="#507 CD1" ForeColor="Whit e" Font-Bold="True"></FooterStyle>

    <Columns>
    <asp:CommandFie ld ShowSelectButto n="True">
    </asp:CommandFiel d>
    <asp:BoundFie ld DataField="intI TPCodePK" SortExpression= "intITPCode PK" HeaderText="ITP Code"></asp:BoundField>
    <asp:BoundFie ld DataField="strs ubmitter" SortExpression= "strsubmitt er" HeaderText="Sub mitter"></asp:BoundField>
    <asp:BoundFie ld DataField="datR equested" SortExpression= "datRequest ed" HeaderText="Dat e Requested"></asp:BoundField>
    <asp:BoundFie ld DataField="datR equired" SortExpression= "datRequire d" HeaderText="Dat e Required"></asp:BoundField>
    </Columns>

    <RowStyle BackColor="#EFF 3FB"></RowStyle>
    <EditRowStyle BackColor="#246 1BF"></EditRowStyle>
    <SelectedRowSty le BackColor="#D1D DF1" ForeColor="#333 333" Font-Bold="True"></SelectedRowStyl e>
    <PagerStyle BackColor="#246 1BF" ForeColor="Whit e" HorizontalAlign ="Center"></PagerStyle>
    <HeaderStyle BackColor="#507 CD1" ForeColor="Whit e" Font-Bold="True"></HeaderStyle>
    <AlternatingRow Style BackColor="Whit e"></AlternatingRowS tyle>
    </asp:GridView>




    <asp:GridView id="GVITPDetail s" runat="server" AutoGenerateCol umns="False" DataKeyNames="i ntITPCodeFK">
    <Columns>
    <asp:BoundFie ld DataField="intI TPCodeFK" SortExpression= "intITPCode FK" HeaderText="ITP Code"></asp:BoundField>
    <asp:BoundFie ld DataField="intI temCodePK" SortExpression= "intItemCod ePK" HeaderText="Ite m Code"></asp:BoundField>
    <asp:BoundFie ld DataField="strI temType" SortExpression= "strItemTyp e" HeaderText="Ite m Type"></asp:BoundField>
    <asp:BoundFie ld DataField="intQ uantity" SortExpression= "intQuantit y" HeaderText="Qua ntity"></asp:BoundField>
    </Columns>

    <RowStyle BackColor="#EFF 3FB"></RowStyle>
    <EditRowStyle BackColor="#246 1BF"></EditRowStyle>
    <SelectedRowSty le BackColor="#D1D DF1" ForeColor="#333 333" Font-Bold="True"></SelectedRowStyl e>
    <PagerStyle BackColor="#246 1BF" ForeColor="Whit e" HorizontalAlign ="Center"></PagerStyle>
    <HeaderStyle BackColor="#507 CD1" ForeColor="Whit e" Font-Bold="True"></HeaderStyle>
    <AlternatingRow Style BackColor="Whit e"></AlternatingRowS tyle>
    </asp:GridView>



    Thank You in Advance
Working...