Click here to Skip to main content
15,880,132 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a gridview control and when I'm in edit mode I would like to have one drop downs, but the second(textbox) and third(textbox) is based on the first. So if I chose Size, the length and width will be shown based on the selected size. I can update it for the fisrt row but having trouble with the second row.

for the first row in grid view,the size can update successfully.But for 2nd row,the size cannot be select because there has an error.

Thanks.

VB
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
       Dim sqlsize, a, b, c As String
       Dim rowcount As String


       rowcount = GridView1.Rows.Count

       ' If rowcount > 0 Or rowcount < 21 Then
       ' Dim rowIndex As Integer
       For rowIndex As Integer = 0 To rowcount - 1
           'rownumber = GridView1.Rows(rowIndex).Cells(0).Text
           Dim LabelL As Label = GridView1.Rows(rowIndex).Cells(1).FindControl("LabelID1")

           Dim row As GridViewRow = GridView1.SelectedRow

           Dim ddl1 As DropDownList = GridView1.Rows(rowIndex).Cells(3).FindControl("ddlSizeG")
           'Dim ddl As DropDownList = DirectCast(sender, DropDownList)
           'Dim gRow__1 As GridViewRow = DirectCast(ddl.NamingContainer, GridViewRow)
           'Dim myGrid As GridView = DirectCast(gRow__1.NamingContainer, GridView)
           'myGrid.SelectedIndex = gRow__1.RowIndex

           sqlsize = "select size_length, size_width ,size_height from mpc_product_size where size_code = '" & ddl1.SelectedValue & "'"
           db.OpenTableMPC(sqlsize)

           If Not db.Eof Then
               'If ddlSize.SelectedValue = "NA" Then
               a = db.Item("size_length")
               Dim txtL As TextBox = GridView1.Rows(rowIndex).Cells(4).FindControl("txtL")
               txtL.Text = FormatNumber(CDbl(a), "0")

               b = db.Item("size_width")
               Dim txtw As TextBox = GridView1.Rows(rowIndex).Cells(5).FindControl("txtW")
               txtw.Text = FormatNumber(CDbl(b), "0")

               c = db.Item("size_height")
               Dim txth As TextBox = GridView1.Rows(rowIndex).Cells(6).FindControl("txtH")
               txth.Text = FormatNumber(CDbl(c), "0")


               If ddl1.SelectedValue = "NA" Then
                   txtL.ReadOnly = False
                   txtw.ReadOnly = False
                   txth.ReadOnly = False
               Else
                   ddl1.Focus()
                   txtL.ReadOnly = True
                   txtw.ReadOnly = True
                   txth.ReadOnly = False

               End If

           End If
           db.MoveNext()

           If db.Eof Then
               Exit For
           End If
       Next

   End Sub
Posted
Updated 27-Mar-12 22:53pm
v2
Comments
RDBurmon 28-Mar-12 10:02am    
Please post exception detail here.
Member 8412080 28-Mar-12 20:32pm    
what is exception detail?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900