473,569 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing data grid column

Hi

I have a hidden (visible=false) column on a gridview bound to a sql server
table. I am trying to access the field as;

For Each row As GridViewRow In grdEvents.Rows
If row.RowType = DataControlRowT ype.DataRow Then
bf = CType(row.Cells (row.Cells.Coun t - 1).FindControl( "event id"),
BoundField)
End if
Next

but I get the 'System.Web.UI. Control' cannot be converted to
System.Web.UI.W ebControls.Boun dField' error. When I try to access it using
row.Cells(12).T ext then it returns a blank value.

How can I access the relevant gridview column?

Thanks

Regards
Aug 27 '06 #1
3 1767
"John" <Jo**@nospam.in fovis.co.ukwrot e in message
news:Ok******** ******@TK2MSFTN GP04.phx.gbl...
I have a hidden (visible=false) column on a gridview bound to a sql server
table. I am trying to access the field as;

For Each row As GridViewRow In grdEvents.Rows
If row.RowType = DataControlRowT ype.DataRow Then
bf = CType(row.Cells (row.Cells.Coun t - 1).FindControl( "event id"),
BoundField)
End if
Next

but I get the 'System.Web.UI. Control' cannot be converted to
System.Web.UI.W ebControls.Boun dField' error.
Hmm - not precisely certain what you're trying to do here... Clearly, you
don't actually need to convert a column into a BoundField or anything else
just to interrogate its contents...
When I try to access it using row.Cells(12).T ext then it returns a blank
value.
Sounds like you've discovered one of the new features of GridViews, whereby
hidden columns are not saved in ViewState by default...
How can I access the relevant gridview column?
Set the column Visible = True immediately before calling the GridView's
DataBind method, then set it Visible = False immediately afterwards...
Aug 27 '06 #2
Hi

I have used the 'Configure Data Source' to bind the gridview. Where would I
find the databind method in this case?

Thanks

Regards

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:e$******** ******@TK2MSFTN GP06.phx.gbl...
"John" <Jo**@nospam.in fovis.co.ukwrot e in message
news:Ok******** ******@TK2MSFTN GP04.phx.gbl...

>How can I access the relevant gridview column?

Set the column Visible = True immediately before calling the GridView's
DataBind method, then set it Visible = False immediately afterwards...

Aug 27 '06 #3
KJ
Hello John,

I am guessing you used an ObjectDataSourc e control to act as a
datasource for the gridview? Check the following:

The DataSourceID property of the gridview is set to that of the
objectdatasourc e.
WHen you call DataBind() on the gridview, the SelectMethod of the
objectdatasourc e is implicitly called.

John wrote:
Hi

I have used the 'Configure Data Source' to bind the gridview. Where would I
find the databind method in this case?

Thanks

Regards

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:e$******** ******@TK2MSFTN GP06.phx.gbl...
"John" <Jo**@nospam.in fovis.co.ukwrot e in message
news:Ok******** ******@TK2MSFTN GP04.phx.gbl...

How can I access the relevant gridview column?
Set the column Visible = True immediately before calling the GridView's
DataBind method, then set it Visible = False immediately afterwards...
Aug 28 '06 #4

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

Similar topics

6
1798
by: Mike Kirkpatrick | last post by:
I have this data grid which consists of 3 pick lists. The first pick list is to affect the data binding of the other two. I have figured out how to do the data binding by column. However, I do not want the first pick list to affect the other rows. At this time, when I change the first pick list, it is causing the second and third pick lists...
2
2491
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is the OID of Person), the information of the person matching the selected OID is shown in the Textboxes (Name, Address, id, etc) and the courses this...
2
2616
by: damonf | last post by:
I'm currently trying to add an ASP hyperlink to a template column in a datagrid. The normal hyperlink column doesn't give me the ability to add attributes to the item. In my grid there are four columns. Three are databound to a dataset and one is a template column. I need to be able to access each item in the template column (getting...
4
4366
by: Souri Challa | last post by:
Hello All, When a datagrid in a web form is getting re populated from view state on post back, it is firing the datagrid Item Created event but the DataGridItem(e.Item.DataItem is null) in the event arguments has no values. Is there any way to access and manipulate the row contents in this case ? Thanks in advance for any insigts in to...
6
3827
by: Hutty | last post by:
I've looked around and have yet to find anything that would answer my question regarding formating a column in a datagrid. My grid looks like this as far as data" AMHQCON|51300.01|-3147 The first two columns are pretty much text column, but subsequent columns 1-12 are numerical. I'm trying to get the thousand separator to work. Any...
2
2300
by: pmud | last post by:
Hi, I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column in data grid is Edit Column. I want to display all columns in Excel except for the Edit column. The following code which I am using allows exporting only from text data from data grid & not from Edit columns which are link buttons. How to leave this column...
15
3939
by: anthonyberet | last post by:
Hello again - rather a newbie here... I want to work on a sudoku brute-forcer, just for fun. I am considering different strategies, but first I need to decide on the data-structure to use for the progress/solution grid. This being a square, I would have used a 9x9 2-dimensional array in my teenage years back in the 80's, using BASIC.
1
5207
by: Josh | last post by:
Using Visual Studio 2003, C#, .NET 1.1. I have a web form with a few textboxes, a couple of dropdown lists, and a data grid. The data grid is populated from a SQL stored procedure. The user can select a row to edit by clicking an EDIT link, which triggers an Edit command. The textboxes and dropdowns are then populated with the data from...
3
2173
by: gilbert3b2g | last post by:
I'm new to Python, and programming in general. What I'm trying to do here is to load a list of accounts from a file on my harddrive into a string of Buttons in Tkinter, and when I press one of the Buttons, which has one of my account name, it will load that account into a new window. But I don't understand how to code the proccess that would...
6
2932
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1) Constraint pk_table1 Primary Key,
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
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. ...
0
8132
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...
1
7678
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...
0
7982
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...
0
6286
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...
1
5514
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...
0
5222
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...
1
2116
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 we have to send another system

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.