468,514 Members | 1,669 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,514 developers. It's quick & easy.

Edit in DataGrid

DC
Newbie's question about .NET datagrid
If I use:
<asp:EditCommandColumn></asp:EditCommandColumn>
When I edit a row, it will automatically show Update and Cancel Link.

But when I use:
<asp:Button id="btnEdit" runat="server" Text="Edit" CommandName="Edit"
CssClass="clickable"Width="50px" />

When I edit a row, the Update/Cancel links don't show up.

Can someone help me?

This is my code:
<asp:TemplateColumn HeaderText="Action" ItemStyle-Width="120px">
<ItemTemplate>
<asp:Button id="btnEdit" runat="server" Text="Edit"
CommandName="Edit" CssClass="clickable"
Width="50px" />
<asp:Button id="btnDelete" runat="server" Text="Delete"
CommandName="Delete" CssClass="clickable"
Width="50px" />
</ItemTemplate>
</asp:TemplateColumn>
- DC
Nov 18 '05 #1
4 4133
Jos
DC wrote:
Newbie's question about .NET datagrid
If I use:
<asp:EditCommandColumn></asp:EditCommandColumn>
When I edit a row, it will automatically show Update and Cancel Link.

But when I use:
<asp:Button id="btnEdit" runat="server" Text="Edit" CommandName="Edit"
CssClass="clickable"Width="50px" />

When I edit a row, the Update/Cancel links don't show up.

Can someone help me?

This is my code:
<asp:TemplateColumn HeaderText="Action" ItemStyle-Width="120px">
<ItemTemplate>
<asp:Button id="btnEdit" runat="server" Text="Edit"
CommandName="Edit" CssClass="clickable"
Width="50px" />
<asp:Button id="btnDelete" runat="server" Text="Delete"
CommandName="Delete" CssClass="clickable"
Width="50px" />
</ItemTemplate>
</asp:TemplateColumn>


Put the Update and Delete buttons in an EditItemTemplate, not
in an ItemTemplate.

--

Jos
Nov 18 '05 #2
DC
>
Put the Update and Delete buttons in an EditItemTemplate, not
in an ItemTemplate.

--

Jos

Something like this?
<asp:TemplateColumn SortExpression="" HeaderText="Action">
<EditItemTemplate>
<asp:Button id="btnEdit" runat="server" Text="Edit"
CommandName="Edit" CssClass="clickable"
Width="50px" />
<asp:Button id="btnDelete" runat="server" Text="Delete"
CommandName="Delete" CssClass="clickable"
Width="50px" />

</EditItemTemplate>
</asp:TemplateColumn>

The column shows nothing, no buttons at all.
What am I missing?
Nov 18 '05 #3
Jos
DC wrote:
Put the Update and Delete buttons in an EditItemTemplate, not
in an ItemTemplate.

--

Jos

Something like this?
<asp:TemplateColumn SortExpression="" HeaderText="Action">
<EditItemTemplate>
<asp:Button id="btnEdit" runat="server" Text="Edit"
CommandName="Edit" CssClass="clickable"
Width="50px" />
<asp:Button id="btnDelete" runat="server" Text="Delete"
CommandName="Delete" CssClass="clickable"
Width="50px" />

</EditItemTemplate>
</asp:TemplateColumn>

The column shows nothing, no buttons at all.
What am I missing?


Dit you handle the EditCommand event on the datagrid?

Something like this:
Sub DataGrid1_OnEditCommand(Sender As Object, E As DataGridCommandEventArgs)
DataGrid1.EditItemIndex = e.Item.ItemIndex
BindGrid()
End Sub

and:

<asp:DataGrid id="DataGrid1" OnEditCommand="DataGrid1_OnEditCommand"
runat="server">

--

Jos Branders
Nov 18 '05 #4
Hello,
<asp:editCommandColumn> is in-build feature. So, when you use
this, on edit, you will get other two buttons. If you use
<asp:button>, you will not get buttons for update&calcel. So, you have
to write code on your own for this. <asp:button> is a web control for
buttons to submit pages to server. Similary you can use this for
"Edit", but for update&cancle, you have to write code on your own.

I hope this will help you.

-Sri.

"DC" <dc*******@email.com> wrote in message news:<OK**************@tk2msftngp13.phx.gbl>...
Newbie's question about .NET datagrid
If I use:
<asp:EditCommandColumn></asp:EditCommandColumn>
When I edit a row, it will automatically show Update and Cancel Link.

But when I use:
<asp:Button id="btnEdit" runat="server" Text="Edit" CommandName="Edit"
CssClass="clickable"Width="50px" />

When I edit a row, the Update/Cancel links don't show up.

Can someone help me?

This is my code:
<asp:TemplateColumn HeaderText="Action" ItemStyle-Width="120px">
<ItemTemplate>
<asp:Button id="btnEdit" runat="server" Text="Edit"
CommandName="Edit" CssClass="clickable"
Width="50px" />
<asp:Button id="btnDelete" runat="server" Text="Delete"
CommandName="Delete" CssClass="clickable"
Width="50px" />
</ItemTemplate>
</asp:TemplateColumn>
- DC

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Tamir Khason | last post: by
reply views Thread by Steve Kallal | last post: by
3 posts views Thread by Leo | last post: by
3 posts views Thread by Tim::.. | last post: by
1 post views Thread by David Sagenaut | last post: by
9 posts views Thread by rn5a | last post: by
8 posts views Thread by =?Utf-8?B?bWlrZWc=?= | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.