473,386 Members | 1,673 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,386 software developers and data experts.

GV Databound Event vs DG ItemDataBound Event

It seems every time I try to use the GridView to do what I used to do with
the DataGrid I run into differences that make me want to got back to the
datagrid. for instance...

the DataGrid ItemDataBound event was a very valuable event to customize
binding. We could refer to the item at being bound by referencing
e.item.whatever.

Now with the GridView there is a "DataBound" event but item is no longer a
property! In fact there are no prooperties in the event arguments so we
cannot say e.item. there are just four methods (Equals,GetHashCode,GetType,
and ToString). So how can we reference an item? the documentation is
silent on this - unlike the 1.1 datagrid documentation.

Are there any discussions anywhere on how to do things with the Gridview
that used to be so easy with the DataGrid?

(one of our developers posted on this issue and someone responded that we
should use e.row but there is no row property.)

--
Regards,
Gary Blakely
Aug 17 '06 #1
1 2114
Hi Gary,

Glad to work with you on this GridView question again.

You need to use the RowDataBound event. The DataBound event is fired when
the data binding is completed.

protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int productID = (int)DataBinder.Eval(e.Row.DataItem,
"ProductID");
string productName = (string)DataBinder.Eval(e.Row.DataItem,
"ProductName");
}
}

Hope this helps. Please feel free to post here if anything is unclear.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 18 '06 #2

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

Similar topics

2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
6
by: VB Programmer | last post by:
I have an itemtemplate in a datagrid. I'm trying to set it's value based on data. Having no trouble with the textbox. But, how do I do the same thing for a dropdownlist???? <ItemTemplate>...
1
by: simon | last post by:
I have dataRepeater and I use its dataBound event: Private Sub rprPlists_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles...
0
by: Steve | last post by:
Hi, I have a problem here with bounding data inside a datalist. Currently I am working on a page which I can have a list of items using a datalist(listA). Inside this datalist(listA) i would...
1
by: Roy | last post by:
Hey all, This is a fairly broad question, but why is it that my datagrid hits the ItemDataBound event 3 times? Basically, I placed a response.write in all sub and functions in my codebehind and...
4
by: MasterChief | last post by:
I have an insert template textbox that is bound to a field in SQL. Since it is the insert template it really doesn't have anything in it. How do I set the default text? Like for example if I have a...
1
by: greenb | last post by:
I'm using the ItemDataBound event of the DataGrid to highlight cells that are outside an acceptable range. Each row has a button column (CommandName='Select'), that is used to display addtional...
2
by: ree321 | last post by:
I tried moving an ASP.net project form 1.1 to 2.0. But I am having problems with getting the OnItemDataBound function to run for a datagrid, in 2.0. It only gets called up if AutoGenerateColumns...
2
by: Nathan Sokalski | last post by:
I am using databinding and the Repeater control to display the results of a database query. I normally use the DataBinder.Eval method for this, but in a scenario I am currently dealing with I would...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.