Desperate - Gridview each row different from DataGrid - why not works?

  • Thread starter Thread starter K B
  • Start date Start date
K

K B

Hi, For each row in a gridview, I need to get the control type and the
value assigned. This used to work in DataGrid but now I get an
ArgumentOutofRange exception.

PLEASE HELP ME...

If i.Cells(4).Controls(0).GetType Is GetType(DropDownList) Then
sAnswer = CType(i.Cells(4).Controls(0), DropDownList).SelectedItem.Text
End If

Thanks,
Kit
 
GridView is way better that DG :-)

just use

dim myDDLvalue as string
myDDLvalue = ctype( gv.FindControl("yourDropDownListName"),
DropDownList).SelectedValue


:-)
 
Thanks for answering! One wrinkle. I'm building a gridview with one
column dynamically generated as follows. This could be a text box,
dropdownlist, radiobuttonlist or checkboxlist. But switching this code
from datagrid to gridview no longer works. When saving, I need to find
it by control Type. Or how can I assign an ID for added control? Any
thoughts?

THANKS, Kit

Dim ddlResp As New DropDownList

Dim sTest As String =
dgTable(gv1).Rows(e.Row.DataItemIndex)(5)
Dim textdelimiter As String
textdelimiter = ";"
Dim splitout = Split(sTest, textdelimiter)
Split(sTest, textdelimiter)

Dim list = New ArrayList

Dim i As Integer
For i = 0 To UBound(splitout)
list.Add(Trim(splitout(i)))
Next

ddlResp.DataSource = list
ddlResp.DataBind()
e.Row.Cells(4).Controls.Add(ddlResp)
ddlResp.EnableViewState = True
 
Back
Top