473,503 Members | 5,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting value from GridView

I have a GridView and when the SelectedIndexChange occurs I want to put the
value of a BoundField into a TextBox (txtPropertyID) on the page. Below is
the code I am using but it is not getting the value. Can someone help?
Thanks
David

Protected Sub gvPropertyClosings_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs)
Dim gvrow As GridViewRow = gvPropertyClosings.SelectedRow
txtPropertyID.Text =
Convert.ToString(DataBinder.Eval(gvrow.DataItem, "PropertyID"))
End Sub
Jan 4 '08 #1
3 9319
"David C" <dl*****@lifetimeinc.comwrote in message
news:uV**************@TK2MSFTNGP02.phx.gbl...
Below is the code I am using but it is not getting the value.
That's right - the DataItem property is available only during the GridView's
RowDataBound event:
http://msdn2.microsoft.com/en-us/lib....dataitem.aspx
Can someone help?
Store the value during the RowDataBound event, either as part of the
GridView's DataKeyNames property or in a hidden field in one of the row's
cells...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 4 '08 #2
But I only want the value of the Selected row cell. How do I specify since
RowDataBound fires on each record correct?

David
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:uj**************@TK2MSFTNGP02.phx.gbl...
"David C" <dl*****@lifetimeinc.comwrote in message
news:uV**************@TK2MSFTNGP02.phx.gbl...
>Below is the code I am using but it is not getting the value.

That's right - the DataItem property is available only during the
GridView's RowDataBound event:
http://msdn2.microsoft.com/en-us/lib....dataitem.aspx
>Can someone help?

Store the value during the RowDataBound event, either as part of the
GridView's DataKeyNames property or in a hidden field in one of the row's
cells...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 4 '08 #3
"David C" <dl*****@lifetimeinc.comwrote in message
news:u8**************@TK2MSFTNGP06.phx.gbl...
But I only want the value of the Selected row cell. How do I specify
since RowDataBound fires on each record correct?
No, you're missing the point...

You're trying to interrogate the DataItem property in the GridView's
SelectedIndexChanged event, but the DataItem property is available only in
the RowDataBound event...

That's why if, in any event other than the RowDataBound event, you require
any value from the the GridView's underlying data source which is not bound
to the GridView's cells or DataKeyNames property, you'll need to add it to
the GridView during the RowDataBound event...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 5 '08 #4

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

Similar topics

15
2943
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting...
6
2237
by: melanieab | last post by:
Hi, Easy question. It seems to me that I'm following the examples correctly, but apparently I'm not. I'm trying to retrieve the data from a row called "row" and a column called "File". This is...
5
2276
by: velu | last post by:
Problem in getting value from textbox & radiobuttonlist to a valuable inside a datagid. I want to insert a record into a table thru datagrid. Here is the code (see below) Private Sub...
2
4097
by: Kevin Walzer | last post by:
I'm trying to construct a simple Tkinter GUI and I'm having trouble with getting the value of an entry widget and passing it onto a callback function. But I'm not grokking variable scope correctly....
4
4564
by: bushi | last post by:
hi ! i have following code to display some text on a web form,after getting it from database. <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate>...
0
4918
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...
3
1547
by: koneru9999 | last post by:
i have one storedprocedure in database.from that i can get last login time .i fetched that value and assigned that value to session in one servlet class.from that session i am getting that last login...
1
1220
by: renatois | last post by:
Getting value from GridView Hi guys, I have a GridView and I need to access a value of an ID field on an event. I converted this field into template and the name of the label control in...
4
19132
by: TisMe | last post by:
Hi All, Can anyone help me out here? I am trying to get the value of a GV cell, code is below (Obviously not useful - But this is what I have ended up with during my testing). I have bound...
1
1018
by: Remco | last post by:
Hello, I know that in a databound control I can render the value of a certain field with the syntax <%#Eval("PROD_NAME")%>. But how do I, in design mode (not in code behind), display something...
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
6970
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...
0
7441
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...
0
5558
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,...
0
4663
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...
0
3156
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...
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
366
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...

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.