473,800 Members | 3,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview - Pull value from one cell in one row

Hi, I'm a newbie and I'm looking for some help. I'm programming in VB.Net.

I have a simple gridview and when the user hits the Edit link, the gridview
changes to edit mode. I replaced the Textboxes with labels and I turn off
the Update command because I want to write my own update command. I can not
figure out how to pull the value from a cell in the row the user hit Edit
on.

Example: User hits edit on row 10 and the value I want to pull in in column
5 and is a Label with the ID of AnswerID. How do I get that value. This is
what I've tried and it didn't work.

Gridview.findco ntrol("AnswerID ").tostring
Thanks!

Aug 5 '07 #1
4 5916
pvong wrote:
Hi, I'm a newbie and I'm looking for some help. I'm programming in
VB.Net.
I have a simple gridview and when the user hits the Edit link, the
gridview changes to edit mode. I replaced the Textboxes with labels
and I turn off the Update command because I want to write my own
update command. I can not figure out how to pull the value from a
cell in the row the user hit Edit on.

Example: User hits edit on row 10 and the value I want to pull in in
column 5 and is a Label with the ID of AnswerID. How do I get that
value. This is what I've tried and it didn't work.

Gridview.findco ntrol("AnswerID ").tostring
Gridview.Rows(G ridView.EditInd ex).Cells(5).Fi ndControl("Answ erID").ToString ()

Note that column 5 is the sixth column here (starts from 0).

--

Riki
Aug 5 '07 #2
Thanks for replying. To test this, I created another label (Results)
outside of the gridview to show the value to make sure it works. When I do
this, Results shows this error message.

System.Web.UI.W ebControls.Labe l
"Riki" <ri**@dontnagme .comwrote in message
news:OB******** ******@TK2MSFTN GP04.phx.gbl...
pvong wrote:
>Hi, I'm a newbie and I'm looking for some help. I'm programming in
VB.Net.
I have a simple gridview and when the user hits the Edit link, the
gridview changes to edit mode. I replaced the Textboxes with labels
and I turn off the Update command because I want to write my own
update command. I can not figure out how to pull the value from a
cell in the row the user hit Edit on.

Example: User hits edit on row 10 and the value I want to pull in in
column 5 and is a Label with the ID of AnswerID. How do I get that
value. This is what I've tried and it didn't work.

Gridview.findc ontrol("AnswerI D").tostring

Gridview.Rows(G ridView.EditInd ex).Cells(5).Fi ndControl("Answ erID").ToString ()

Note that column 5 is the sixth column here (starts from 0).

--

Riki

Aug 5 '07 #3
pvong wrote:
Thanks for replying. To test this, I created another label (Results)
outside of the gridview to show the value to make sure it works. When I do
this, Results shows this error message.

System.Web.UI.W ebControls.Labe l
Gridview.Rows(G ridView.EditInd ex).Cells(5).Fi ndControl("Answ erID").ToString ()
produces the name of the control.

To get the content, use (VB.NET)
CType(Gridview. Rows(GridView.E ditIndex).Cells (5).FindControl ("AnswerID"),La bel).Text
In C#:
((Label)Gridvie w.Rows(GridView .EditIndex).Cel ls(5).FindContr ol("AnswerID")) .Text

--

Riki
Aug 5 '07 #4
Perfect! Thanks!
"Riki" <ri**@dontnagme .comwrote in message
news:ey******** ******@TK2MSFTN GP02.phx.gbl...
pvong wrote:
>Thanks for replying. To test this, I created another label (Results)
outside of the gridview to show the value to make sure it works. When I
do this, Results shows this error message.

System.Web.UI. WebControls.Lab el

Gridview.Rows(G ridView.EditInd ex).Cells(5).Fi ndControl("Answ erID").ToString ()
produces the name of the control.

To get the content, use (VB.NET)
CType(Gridview. Rows(GridView.E ditIndex).Cells (5).FindControl ("AnswerID"),La bel).Text
In C#:
((Label)Gridvie w.Rows(GridView .EditIndex).Cel ls(5).FindContr ol("AnswerID")) .Text

--

Riki

Aug 5 '07 #5

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

Similar topics

1
3868
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this using a GridView that has ViewState enabled, an ObjectDataSource to process the submitted list, textboxes for getting new item data and an add button. Does this approach sound feasible or are there better alternatives? My problem is that I don't...
6
8274
by: Dabbler | last post by:
I have a dropdownlist in a GridView ItemTemplate. I need to bind the ddl to an SqlDataSource, then have a value from a boundfield in the row be passed as the keyfield for select where clause. Im trying to load the ddl with a list of dates from another table keyed on GridView row field that only apply to this row. Any suggestions would be appreciated.
0
8566
by: Innova | last post by:
Hi, We are working on a gridview inside the gridview (parent-child) scenario. The data of child grid will depend on the data of parent. Objectives: 1.Add new row in parent grid after each row and add child grid into that row because the columns in child grid are same as parent grid and we want to align them with the cols of parent grid. 2. If there is data for child grid we show a plus image in the parent row (in the row above the...
1
2840
by: ad | last post by:
I set a row of gridview different color when one value in the first column if greater the the value in the second column. How can I do?
7
10389
by: aljamala | last post by:
Hi, I was wondering if there is a way to make a single cell readonly within a GridView? I know you can do it for a column but what about a cell within that column? Thanks!
1
27505
by: K B | last post by:
I would like to create a gridview as below: Project Name 1-1 1-2 1-3 1-4 1-5 1-6 Project 1 BLUE BLUE BLUE BLUE GREEN GREEN more projects I would like to fill the cell with a solid color based on the value of the cell (e.g., documents that are complete (blue) or not complete (green). In effect have a solid bar indicator going across each row. I know how to color the cell based on the value, but not the click...
1
4009
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. Depends on the pull down list selection, I use script.aculo.us to validate the user input before submit and pass the necessary data, such as contact type, contact information and ranking to a php program for updating. This form should allow multiple...
3
3312
by: Bill Gower | last post by:
I have an cell which contains a field member which is filled with String.Empty. When I retrieve the value in the cell with Cells.Text.ToString() and try to compare it to String.Empty, I can't because it contains "&nbsp". I really don't want to compare the value to that so how can I retrieve an empty cell so that it is String.Empty. Bill
14
91376
by: Mike | last post by:
I have a gridview that has a button in the last cell of each row. I want to get the text from cell 1 for that row the button was clicked on. So if my gridview looks like this: N-12 BMW N-35 Mercedes if my user clicks row 2, I want to see Mercedes, How can I do that? I have a buttonClick event for my select button, I'm trying to pull the values using the DataKeyName, but I keep getting 'object reference...
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,...
0
10495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10269
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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...
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
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5597
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.

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.