S
Steve Black
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
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