473,378 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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

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

*** Sent via Developersdex http://www.developersdex.com ***
May 23 '06 #1
2 1890
GridView is way better that DG :-)

just use

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

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"K B" <ka**********@comcast.net> escreveu na mensagem
news:%2****************@TK2MSFTNGP03.phx.gbl...
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

*** Sent via Developersdex http://www.developersdex.com ***

May 23 '06 #2
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


*** Sent via Developersdex http://www.developersdex.com ***
May 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ber.janssens | last post by:
Hi, In ASP.NET 2.0, I have a GridView with 2 CommandFields, how can I determine in the SelectedIndexChanged event which CommandField is clicked? <asp:GridView ID="gvOrderList" runat="server"...
0
by: kieran | last post by:
Hi, I was using the datagrid and am now starting to use the gridview in asp.net 2.0. I used to use the first below sub for when i would mouseover a row - this highlighted the row but did not...
6
by: InK_ | last post by:
Hi, All! I need to accomplish such functionality: A data row should be highlighted with the other color if cursor is over it. I also have the old code from asp which uses <tr...
6
by: GaryDean | last post by:
I liked the DataGrid because I was familiar in walking through it to do custom filling and retrieval of data in cases where standard binding wouldn't do the job. I read somewhere that the object...
2
by: Chris Davoli | last post by:
How do you enable a check box in the GridView. I selected Checkbox Field in the Columns of the GridView, and the check box shows up in the Grid view, but it is disabled. How do I enable it so I can...
0
by: John Smith | last post by:
ASP.Net 2.0 / C# / IIS 6 I have 2 pages. The master page consists of a tabbed menu created using the Menu and MultiView controls. Something like this: ...
0
by: John Smith | last post by:
If anyone can help, I would very muchly appreciate it. I have a main page that uses the .net 2.0 menu control with the multiview controls as the menu choices. This works fine. One of the menu...
1
by: rn5a | last post by:
I was using a DataView to bind records from a DB table to a DataGrid using the following code: Dim sqlDapter As SqlDataAdapter Dim dSet As DataSet Dim dView As DataView sqlDapter = New...
2
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.