473,396 Members | 2,098 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,396 software developers and data experts.

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 = DataControlRowType.DataRow Then
bf = CType(row.Cells(row.Cells.Count - 1).FindControl("event id"),
BoundField)
End if
Next

but I get the 'System.Web.UI.Control' cannot be converted to
System.Web.UI.WebControls.BoundField' error. When I try to access it using
row.Cells(12).Text then it returns a blank value.

How can I access the relevant gridview column?

Thanks

Regards
Aug 27 '06 #1
3 1760
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:Ok**************@TK2MSFTNGP04.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 = DataControlRowType.DataRow Then
bf = CType(row.Cells(row.Cells.Count - 1).FindControl("event id"),
BoundField)
End if
Next

but I get the 'System.Web.UI.Control' cannot be converted to
System.Web.UI.WebControls.BoundField' 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).Text 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**@markNOSPAMrae.comwrote in message
news:e$**************@TK2MSFTNGP06.phx.gbl...
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:Ok**************@TK2MSFTNGP04.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 ObjectDataSource control to act as a
datasource for the gridview? Check the following:

The DataSourceID property of the gridview is set to that of the
objectdatasource.
WHen you call DataBind() on the gridview, the SelectMethod of the
objectdatasource 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**@markNOSPAMrae.comwrote in message
news:e$**************@TK2MSFTNGP06.phx.gbl...
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:Ok**************@TK2MSFTNGP04.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
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...
2
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...
2
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...
4
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...
6
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...
2
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...
15
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...
1
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...
3
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...
6
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)...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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,...

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.