473,320 Members | 1,948 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,320 software developers and data experts.

Getting Text from rows of gridview

I have a gridview that is populated from a SortedList. In the
gridview I have a text box that the user can update, when they click
update I want to remove the entry from the list and readd it with the
updated item. My problem is when I try to get the text that is in the
cells of the gridview it returns nothing. I remove the item from the
list and that works fine so I know it's getting the proper row.

Here's my code. I found most of this on Microsoft's site.

<code>
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
' Retrieve the row that contains the button clicked
' by the user from the Rows collection.
Dim row As GridViewRow = destServersView.Rows(index)

' Create a new ListItem object for the Server Name in the
row.
Dim sName As New ListItem()
sName.Text = Server.HtmlDecode(row.Cells(0).Text)

' Create a new ListItem object for the Destination Folder
in the row.
Dim sDestFolder As New ListItem()
sDestFolder.Text = Server.HtmlDecode(row.Cells(1).Text)

Me.serverList.Remove(selectedIndex.ToString)
Me.serverList.Add(selectedIndex.ToString, sName.ToString &
"; " & sDestFolder.ToString)
</code>

Any suggestions.

Thanks
Robert

Apr 19 '07 #1
1 1861
On Apr 19, 4:27 pm, rhoenig <robert.hoe...@gmail.comwrote:
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
' Retrieve the row that contains the button clicked
' by the user from the Rows collection.
Dim row As GridViewRow = destServersView.Rows(index)
That's fine

' Create a new ListItem object for the Server Name in the
row.
Dim sName As New ListItem()
sName.Text = Server.HtmlDecode(row.Cells(0).Text)
Is it a place where you have a problem?
try to debug the code...

simply add as follows:

Response.Write "row.Cells(0)=" & Server.HtmlDecode(row.Cells(0))

It should return a result.
' Create a new ListItem object for the Destination Folder
in the row.
Dim sDestFolder As New ListItem()
sDestFolder.Text = Server.HtmlDecode(row.Cells(1).Text)

Add

Response.Write "row.Cells(0)=" & Server.HtmlDecode(row.Cells(1))

Me.serverList.Remove(selectedIndex.ToString)
Me.serverList.Add(selectedIndex.ToString, sName.ToString &
"; " & sDestFolder.ToString)
</code>

Any suggestions.

Thanks
Robert

Apr 19 '07 #2

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

Similar topics

4
by: Neil | last post by:
I have a gridview which is being populated with no problems. I want to be able to reference the data from the cells in the row but having followed an example on MSDN cannot get any data to be...
0
by: Mike P | last post by:
How do you get access to the values you have entered under edit mode in a gridview? I only seem to be able to access the values prior to them being edited. protected void...
0
by: reddog | last post by:
Getting the SelectedIndex of a DropDownlist under the ItemTemplate in a GridView is harder than I thought it would be. I have: A Gridview of n rows bound to a DataSet. A DropDownList as an...
0
by: =?Utf-8?B?cGI2NDgxNzQ=?= | last post by:
We have been having this problem for months and always assumed it was because of our somewhat complicated setup. I have just spent almost all of today making this into a simple example that can be...
3
by: GaryDean | last post by:
I have a button field in a gridview defined as follows: <asp:ButtonField ButtonType="Button" CommandName="AcceptOrder" Text="Accept Whole Order"> <ControlStyle Font-Size="X-Small" />...
0
by: David Lozzi | last post by:
Howdy, I have a gridview with a linkbutton in a template column (code is below). When the linkbutton is clicked i want to display a little confirm right in the gridview to confirm deleting the...
2
by: Mike P | last post by:
I am trying to get access to the data in different rows of my gridview on a button click, in a similar way to the one I used with my 1.1 datagrids. But the cells always seem to be empty. Here is...
3
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a gridview with one of the columns as a template column with a button. When the user selects the button is there a way to get the row number in the button_Click event? Another one of...
3
by: sailaja71185 | last post by:
Here is my code: using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls;
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.