473,800 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.CommandArgum ent)
' 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.HtmlDeco de(row.Cells(0) .Text)

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

Me.serverList.R emove(selectedI ndex.ToString)
Me.serverList.A dd(selectedInde x.ToString, sName.ToString &
"; " & sDestFolder.ToS tring)
</code>

Any suggestions.

Thanks
Robert

Apr 19 '07 #1
1 1875
On Apr 19, 4:27 pm, rhoenig <robert.hoe...@ gmail.comwrote:
Dim index As Integer = Convert.ToInt32 (e.CommandArgum ent)
' 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.HtmlDeco de(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.HtmlDeco de(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.Tex t = Server.HtmlDeco de(row.Cells(1) .Text)

Add

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

Me.serverList.R emove(selectedI ndex.ToString)
Me.serverList.A dd(selectedInde x.ToString, sName.ToString &
"; " & sDestFolder.ToS tring)
</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
35620
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 displayed in a text box no matter which cell index I provide. I tried a row of code that successfully displays the rowindex of the selected row. The code with comments is below:
0
1831
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 GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { // 1)Convert the row index stored in the CommandArgument property to an Integer int index = e.RowIndex;
0
2387
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 ItemTemplate in the GridView populated with three ListItems. A Button to Submit the form.
0
1753
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 easily reproduced and it seems like a major .NET flaw/limitation that I was hoping you could explain to me as it is really frustrating me. I just want to be able to get info for a row clicked, whether it is a Repeater, GridView, etc. I have...
3
22532
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" /> </asp:ButtonField> In the RowCommand event I have the following code: if ((string)e.CommandName.ToLower() == "acceptorder") { int myRow = int.Parse(e.CommandArgument.ToString());
0
4928
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 row. I tried using the following to grab the index, which appears to work on command columns, but not with buttons in a template? is this true? or am i missing something. how do I get the row index? Its returning the ID of the record, not the index...
2
1816
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 my code : protected void btnSubmit_Click(object sender, EventArgs e) { //get list of pkcustomerrecords and email addresses, put into generic list List<EmailDetailsem = new List<EmailDetails>();
3
11467
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 the columns is a template column that has a label that I have displaying the row number. Thanks -- Paul G Software engineer.
3
1710
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
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7574
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.