I'm using Codebehind. The reason for this is because
the datagrid will show columns that's specified in the
database. Thus it can only be created during run-time.

--- Ben Miller <[EMAIL PROTECTED]> wrote:

> One other question.   Are you using Codebehind or
> inline code?
> 
> This matters because on inline code, the events are
> hooked up automatically, and codebehind can get
> change things based on whether there is a button on
> the datagrid at compiletime.
> 
> Ben Miller
> 
>   ----- Original Message ----- 
>   From: Psychomaniac 
>   To: [EMAIL PROTECTED] 
>   Sent: Wednesday, September 22, 2004 10:08 AM
>   Subject: RE: [AspNetAnyQuestionIsOk] Dynamic
> Datagrids
> 
> 
>   Yes, I actually still have those (OnEditCommand,
>   OnCancelCommand and OnUpdateCommand)
> 
> 
> 
>   --- Rajendra Appalla <[EMAIL PROTECTED]>
>   wrote:
> 
>   > I hope you still have this in the HTML part of
> the
>   > datagrid.        
>   >  
>   >    OnEditCommand="ItemsGrid_Edit"
>   >             OnCancelCommand="ItemsGrid_Cancel"
>   >             OnUpdateCommand="ItemsGrid_Update"
>   >  
>   > Rajendra.
>   >  
>   > -----Original Message-----
>   > From: Psychomaniac
>   > [mailto:[EMAIL PROTECTED] 
>   > Sent: Wednesday, September 22, 2004 11:33 AM
>   > To: [EMAIL PROTECTED]
>   > Subject: RE: [AspNetAnyQuestionIsOk] Dynamic
>   > Datagrids
>   >  
>   > Yes, I did that. But actually, those two piece
> of
>   > code
>   > did not even fire up any events the first time
>   > called.
>   > 
>   > 
>   > 
>   > 
>   > --- Rajendra Appalla
> <[EMAIL PROTECTED]>
>   > wrote:
>   > 
>   > > Are you adding those two columns again in
>   > PostBack??
>   > >  Because you
>   > > should.  The known behavior if you don't add
> those
>   > > columns again in
>   > > postback is that the events won't fire on
> those
>   > > columns.
>   > >  
>   > > Rajendra.
>   > >  
>   > > -----Original Message-----
>   > > From: Psychomaniac
>   > > [mailto:[EMAIL PROTECTED] 
>   > > Sent: Wednesday, September 22, 2004 5:39 AM
>   > > To: [EMAIL PROTECTED]
>   > > Subject: [AspNetAnyQuestionIsOk] Dynamic
> Datagrids
>   > >  
>   > > Hi, I'm trying to build an ASP.NET display
> page
>   > > using
>   > > datagrid. This datagrid must contain:
> ButtonColumn
>   > &
>   > > EditCommandColumn. This is part of my code:
>   > > 
>   > >       <asp:DataGrid id="ItemsGrid"
>   > >            BorderColor="black"
>   > >            BorderWidth="1"
>   > >            CellPadding="3"
>   > >            OnEditCommand="ItemsGrid_Edit"
>   > >            OnCancelCommand="ItemsGrid_Cancel"
>   > >            OnUpdateCommand="ItemsGrid_Update"
>   > >            OnItemCommand="ItemsGrid_Command"
>   > >            AutoGenerateColumns="false"
>   > >            runat="server">
>   > > 
>   > >          <HeaderStyle BackColor="#aaaadd">
>   > >          </HeaderStyle>
>   > > 
>   > >          <Columns>
>   > > 
>   > >             <asp:EditCommandColumn
>   > >                  EditText="Edit"
>   > >                  CancelText="Cancel"
>   > >                  UpdateText="Update" 
>   > >                  HeaderText="Edit item">
>   > > 
>   > >                <ItemStyle Wrap="False">
>   > >                </ItemStyle>
>   > > 
>   > >                <HeaderStyle Wrap="False">
>   > >                </HeaderStyle>
>   > > 
>   > >             </asp:EditCommandColumn>
>   > > 
>   > >             <asp:ButtonColumn 
>   > >                  HeaderText="Delete item" 
>   > >                  ButtonType="LinkButton" 
>   > >                  Text="Delete" 
>   > >                  CommandName="Delete"/>
>   > > 
>   > > Note that I also have defined
> "ItemsGrid_Edit",
>   > > "ItemsGrid_Cancel", "ItemsGrid_Update" and
>   > > "ItemsGrid_Command" in my VB code.
>   > > 
>   > > It all works fine. However, I want to create
> the
>   > > ButtonColumn & EditCommandColumn dynamically
> (i.e.
>   > > during run-time). So I removes those 2 pieces
> of
>   > ASP
>   > > code (asp:ButtonColumn &
> asp:EditCommandColumn)
>   > from
>   > > the aspx, and in my VB code, I add this:
>   > > 
>   > > Dim btnColumn As New ButtonColumn
>   > > btnColumn.ButtonType =
> ButtonColumnType.LinkButton
>   > > btnColumn.HeaderText = "Delete item"
>   > > btnColumn.Text = "Delete"
>   > > btnColumn.CommandName = "Delete"
>   > > 
>   > > Dim editColumn As New EditCommandColumn
>   > > editColumn.HeaderText = "Edit Item"
>   > > editColumn.ButtonType =
>   > ButtonColumnType.LinkButton
>   > > editColumn.UpdateText = "Update"
>   > > editColumn.CancelText = "Cancel"
>   > > editColumn.EditText = "E"
>   > > editColumn.ItemStyle.Wrap = False
>   > > 
>   > > ItemsGrid.Columns.Add(btnColumn)
>   > > ItemsGrid.Columns.Add(editColumn)
>   > > 
>   > > At first, it displays the grid correctly,
> however,
>   > > when I click on "Delete" or the "Edit" link
>   > button,
>   > > it
>   > > never raises the event OnDeleteCommand nor
>   > > OnEditCommand!
>   > > 
>   > > Has anybody experienced this kind of problem
> as
>   > > well?
>   > > Thanks a lot!
>   > > 
>   > > Adrian
>   > > 
>   > > 
>   > >             
>   > > __________________________________
>   > > Do you Yahoo!?
>   > > Read only the mail you want - Yahoo! Mail
>   > SpamGuard.
>   > > http://promotions.yahoo.com/new_mail 
>   > > 
>   > > 
>   > > 
>   > > Yahoo! Groups Sponsor
>   > > ADVERTISEMENT
>   > > click here
>   > >
>   >
>  
>
<http://us.ard.yahoo.com/SIG=129ap372f/M=295196.4901138.6071305.3001176/
>   > >
>   >
>  
>
D=groups/S=1705006764:HM/EXP=1095932372/A=2128215/R=0/SIG=10se96mf6/*htt
>   > > p:/companion.yahoo.com> 
>   > >  
>   > >
>   >
>  
>
<http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=group
>   > > s/S=:HM/A=2128215/rand=166831207> 
>   > >  
> 
=== message truncated ===



                
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to