Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

How do I extract values from a gridview row and pass to another form?

$
0
0

I have a dropdownlist where the user selects a part number which is in turn placed into a gridview table along with the part type.  When the user has selected the correct part number he/she can then click on a button to send this part to the appropriate form for editing.  My routine is below but I have not been able to get it to work.  It appears nothing is getting selected to pass to the next form.  The first cell in gridview is the part number, the second is the part type which should determine which form the part number is sent to.

    Protected Sub Button4_Click(sender As Object, e As System.EventArgs) Handles Button4.Click  'Go To Part
        '0 = PART_NUMBER
        '1 = CompType
        For Each x As GridViewRow In GridView1.Rows
            If x.RowType = DataControlRowType.DataRow Then
                PtNo = x.Cells(0).Text
                Typ = x.Cells(1).Text
            End If
        Next
        If Typ = "Capacitors" Then Response.Redirect("Capacitors1.aspx?Data=" & PtNo)
        If Typ = "Connectors" Then Response.Redirect("Connectors1.aspx?Data=" & PtNo)
        If Typ = "Crystals and Oscillators" Then Response.Redirect("Crystals1.aspx?Data=" & PtNo)
        If Typ = "Diodes" Then Response.Redirect("Diodes1.aspx?Data=" & PtNo)
        If Typ = "ICs" Then Response.Redirect("ICs1.aspx?Data=" & PtNo)
        If Typ = "Inductors" Then Response.Redirect("Inductors1.aspx?Data=" & PtNo)
        If Typ = "Misc" Then Response.Redirect("Misc1.aspx?Data=" & PtNo)
        If Typ = "Relays" Then Response.Redirect("Relays1.aspx?Data=" & PtNo)
        If Typ = "Resistors" Then Response.Redirect("Resistors1.aspx?Data=" & PtNo)
        If Typ = "Switches" Then Response.Redirect("Switches1.aspx?Data=" & PtNo)
        If Typ = "Transformers" Then Response.Redirect("Transformers1.aspx?Data=" & PtNo)
        If Typ = "Transistors" Then Response.Redirect("Transistors1.aspx?Data=" & PtNo)
    End Sub

Does anyone have any suggestions as to what I'm doing wrong?

Thanks


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>