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

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
 
B

Bruno Alexandre

GridView is way better that DG :)

just use

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


:)
 
K

K B

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top