473,396 Members | 1,875 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.

GridView with DataTable as data source and RowDataBound

Tim
I'm using a GridView with its DataSource property set to a DataTable.
During the RowDataBound event, the first row of the DataTable is
reported as a DataControlRowType.Header instead of
DataControlRowType.DataRow. How do I change this behavior?

Right now, I ignore the RowType and just assume all rows are actually
data rows (which in fact they are). However, this bugs me, so I'm
wondering if any one knows how to "properly" work around this problem.

Thanks in advance.

Tim

Aug 24 '07 #1
2 7149
During the RowDataBound event, the first row of the DataTable is
reported as a DataControlRowType.Header instead of
If it is *Row*DataBound event of *GridView*, then it should report
first row of GridView and not DataTable, which is in fact usually
Header (unless turned off or empty data), and can be many other types
too, like footer,pager, empty row etc.

You may want to place your data row specific code in a conditional
block like following

if(e.Row.RowType == DataControlRowType.DataRow)
{
...
}
Aug 26 '07 #2
Tim
On Aug 25, 8:00 pm, Muhammad Naveed Yaseen <mnyas...@gmail.comwrote:
During the RowDataBound event, the first row of the DataTable is
reported as a DataControlRowType.Header instead of

If it is *Row*DataBound event of *GridView*, then it should report
first row of GridView and not DataTable, which is in fact usually
Header (unless turned off or empty data), and can be many other types
too, like footer,pager, empty row etc.

You may want to place your data row specific code in a conditional
block like following

if(e.Row.RowType == DataControlRowType.DataRow)
{
...

}
Yes, that's what I would expect, but when in the RowDataBound
callback, the row with type Header is actually the first row of the
DataTable, not the header row of the GridView.

If I turn off the header in the GridView's properties, I still get the
first row of the DataTable reported as a header row in RowDataBound.

Thanks for the response.

Tim
Aug 27 '07 #3

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

Similar topics

4
by: Congero | last post by:
I'm trying to find a way to bind hierarchical data to a gridview control. I've been able to do this with some third party controls and was wondering if this functionality is available with the...
5
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
6
by: Kevin Attard | last post by:
I am using a GridView inside a UserControl which has a template column for deleting the rows. Before databinding the gridview i am attaching the RowCommand and RowDataBound event. I am using the...
4
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the...
4
by: Tomasz Jastrzebski | last post by:
Hello Everyone, I have a GridView control bound to a plain DataTable object. AutoGenerateEditButton is set to true, Edit button gets displayed, and RowEditing event fires as expected.
1
by: =?Utf-8?B?V2VzbGV5IERhdmlzLCBHZW5lcmFsIER5bmFtaWNz | last post by:
I'm moving from years with the datagrid to a new project, .net 2.0, using GridView controls. Per past practice, it is often a lot easier to inject controls (or special formatting) in RowDataBound...
3
by: =?Utf-8?B?SmVu?= | last post by:
I would like to set the width on 2 columns of a asp.net gridview control, but I'm having trouble making this work. Here is the code I use to create the gridview: 'Create a new data table...
3
by: David C | last post by:
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...
2
by: DC | last post by:
Hi, I am using a GridView to present data in a DataTable, which I store only in ViewState and when the user hits the "OK" button the rows in the DataTable will be used to execute transactions. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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.