Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > EditCommandButton in DataGrid

Reply
Thread Tools

EditCommandButton in DataGrid

 
 
Steve Black
Guest
Posts: n/a
 
      05-18-2004
Hello,

I am trying to add an EditCommand Button to a datagrid. If I
programmatically add the button, like this:

Dim eb As EditCommandColumn

eb = New EditCommandColumn
With eb
.ButtonType = ButtonColumnType.PushButton
.EditText = "Edit"
.UpdateText = "Update"
.CancelText = "Cancel"
.ItemStyle.HorizontalAlign = HorizontalAlign.Center
.HeaderStyle.BorderStyle = BorderStyle.None
End With

prmDataGrid.Columns.Add(eb)


I have no problems at all.

However, if I simply add a static button at design time, like this:

<Columns>
<asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>

....other columns here...
</Columns>

Then when I actually click my Edit button, my code-behind doesn't
fire. I am not altering my datagrid as all. My datagrid control
looks like this:

<asp:datagrid Width="75%" id="dgTest" runat="server"
GridLines="Horizontal" AutoGenerateColumns="False"
OnEditCommand="dgTest_EditCommand">
<HeaderStyle CssClass="MinorTitles"></HeaderStyle>
<Columns>
....
</Columns>
</asp:datagrid>

I'm not sure why my function 'dgTest_EditCommand' will work if I
programmatically add the EditCommandButton but will not work when I
use a static button.

Any ideas?

Thanks,

Steve
 
Reply With Quote
 
 
 
 
Cowboy
Guest
Posts: n/a
 
      05-18-2004
When you place it in the ASP, it does not automagically wire up necessarily
(I think it does if you use the right click "Property Builder", but I have
not tested. To manually wire it up, create the event handler(s) you need and
add Handles EventName to the end. That should solve the problem.

Occasionally, VS.NET will delete handlers (not sure what the cause is), so
getting the Handles syntax down is a godsend.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Steve Black" <> wrote in message
news: om...
> Hello,
>
> I am trying to add an EditCommand Button to a datagrid. If I
> programmatically add the button, like this:
>
> Dim eb As EditCommandColumn
>
> eb = New EditCommandColumn
> With eb
> .ButtonType = ButtonColumnType.PushButton
> .EditText = "Edit"
> .UpdateText = "Update"
> .CancelText = "Cancel"
> .ItemStyle.HorizontalAlign = HorizontalAlign.Center
> .HeaderStyle.BorderStyle = BorderStyle.None
> End With
>
> prmDataGrid.Columns.Add(eb)
>
>
> I have no problems at all.
>
> However, if I simply add a static button at design time, like this:
>
> <Columns>
> <asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update"
> CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
>
> ...other columns here...
> </Columns>
>
> Then when I actually click my Edit button, my code-behind doesn't
> fire. I am not altering my datagrid as all. My datagrid control
> looks like this:
>
> <asp:datagrid Width="75%" id="dgTest" runat="server"
> GridLines="Horizontal" AutoGenerateColumns="False"
> OnEditCommand="dgTest_EditCommand">
> <HeaderStyle CssClass="MinorTitles"></HeaderStyle>
> <Columns>
> ...
> </Columns>
> </asp:datagrid>
>
> I'm not sure why my function 'dgTest_EditCommand' will work if I
> programmatically add the EditCommandButton but will not work when I
> use a static button.
>
> Any ideas?
>
> Thanks,
>
> Steve



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Datagrid: how cut short display of a long description in a datagrid column Brian K. Williams ASP .Net 0 03-02-2004 08:35 PM
RE: Datagrid: how cut short display of a long description in a datagrid column =?Utf-8?B?U3VyZXNo?= ASP .Net 0 03-02-2004 08:31 PM
datagrid in datagrid BK Kim ASP .Net 1 03-02-2004 06:34 AM
Call Datagrid Command column outside datagrid Dave ASP .Net 0 11-20-2003 11:11 AM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57