QUESTION: DataGrid.ItemDataBound Event in which cases does this event fire?
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngdatagridrepeaterdatalist' list.


Bill Bassler
The docs make a general statement "Occurs after an item is data bound to the
DataGrid control."

After running some tests, this general statement does not appear to be true.
It appears that it depends on the item being bound
to the DataGrid?

I've only gotten this event to fire when binding to a DataView. Unless I'm
doing something wrong .... it doesn't fire when binding a DataSet or
DataTable to a grid. "Items" are bound to the grid in all of these cases.

What's the story?

Reply to this message...
 
    
Alex Lowe
Bill,

How are you binding to the DataSet and DataTable? Can we see some code?

Alex - AspFriends.com Moderation Team
Microsoft MVP - ASP.NET

***********************************************************
Translate C# code to VB.NET code at
http://aspalliance.com/aldotnet/examples/translate.aspx
***********************************************************

[Original message clipped]

| = JOIN/QUIT

Reply to this message...
 
    
Bill Bassler
got the event wired from the Page object to the DataGrid object via:
private void InitializeComponent()
{
...
this.DataGrid1.ItemDataBound += new
System.Web.UI.WebControls.DataGridItemEventHandler(this.Item_Bound);

and the event belows appears to fire every row (when it's rendered I hope?)
and I can get a reference to the control id via e.Item.ItemIndex ... I
think.

e.g.
private void Item_Bound(object sender, DataGridItemEventArgs e)
{
Label2.Text = Label2.Text + " " + e.Item.ItemIndex;
}

Question1: What's the best way to inject something like the client-side
script string for each row. Unfortunetely, the Page client-side script
methods don't seem to handle this case.
I'm having trouble getting an instance of the HtmlTextWriter.
<A href="javascript:toggleT('divt1','s')"><IMG src='images/sign_plus.gif'
name=plus1 alt='Click to Expand' width=9 height=9 border=0></A>

Question2: Would I be better off creating my own implementation of the
DataGrid and adding an event handler internally to render the additional
tags?

"Alex Lowe" <Click here to reveal e-mail address> wrote in message
news:686919@aspngdatagridrepeaterdatalist...
[Original message clipped]

Reply to this message...
 
 
System.Data.DataSet
System.Data.DataTable
System.Data.DataView
System.Web.UI.HtmlTextWriter
System.Web.UI.WebControls.DataGrid
System.Web.UI.WebControls.DataGridItemEventArgs
System.Web.UI.WebControls.DataGridItemEventHandler
System.Windows.Forms.DataGrid




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com