468,510 Members | 1,790 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Datagrid / image button to edit

Is there any way to display an image button instead of the traditional
Edit/Update/Cancel push button in a datagrid (with bound data)?
Nov 19 '05 #1
4 6689
Sure. Just use a Template column. This sample has 2 buttons in it - Edit and
Delete.
Note the Delete is wrappen in a Span tag which pops up a Confirm dialog
prior to posting to the server.
If the user clicks No then the dialog closes and no postback occurs. If they
click Yes then the postback occurs.
<asp:TemplateColumn HeaderText="Edit and Delete Buttons">
<ItemTemplate>
<asp:imagebutton CommandName="btnEdit" id="btnEdit" runat="server"
ImageUrl="~/img/edit.gif" ToolTip="Edit"></asp:imagebutton>
<span onclick="return confirm('Do you really want to delete this
record from the system?')">
<asp:imagebutton CommandName="btnDelete" id="btnDelete"
runat="server" ImageUrl="~/img/delete.gif"
ToolTip="Delete"></asp:imagebutton>
</span>
</ItemTemplate>
</asp:TemplateColumn>

--
Joe Fallon

"rkbnair" <rk*****@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
Is there any way to display an image button instead of the traditional
Edit/Update/Cancel push button in a datagrid (with bound data)?

Nov 19 '05 #2
The source code gives syntax errors.

Compiler does not recognize the imageurl etc.

"Joe Fallon" wrote:
Sure. Just use a Template column. This sample has 2 buttons in it - Edit and
Delete.
Note the Delete is wrappen in a Span tag which pops up a Confirm dialog
prior to posting to the server.
If the user clicks No then the dialog closes and no postback occurs. If they
click Yes then the postback occurs.
<asp:TemplateColumn HeaderText="Edit and Delete Buttons">
<ItemTemplate>
<asp:imagebutton CommandName="btnEdit" id="btnEdit" runat="server"
ImageUrl="~/img/edit.gif" ToolTip="Edit"></asp:imagebutton>
<span onclick="return confirm('Do you really want to delete this
record from the system?')">
<asp:imagebutton CommandName="btnDelete" id="btnDelete"
runat="server" ImageUrl="~/img/delete.gif"
ToolTip="Delete"></asp:imagebutton>
</span>
</ItemTemplate>
</asp:TemplateColumn>

--
Joe Fallon

"rkbnair" <rk*****@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
Is there any way to display an image button instead of the traditional
Edit/Update/Cancel push button in a datagrid (with bound data)?


Nov 19 '05 #3
There is no source code error.
This is a copy of code from a fully functioning datagrid.

Ensure you copy all of the code including the <asp:TemplateColumn ...> tag
and place it in your datagrid. Change the name of the image and img folder
to your versions.
--
Joe Fallon

"rkbnair" <rk*****@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
The source code gives syntax errors.

Compiler does not recognize the imageurl etc.

"Joe Fallon" wrote:
Sure. Just use a Template column. This sample has 2 buttons in it - Edit and Delete.
Note the Delete is wrappen in a Span tag which pops up a Confirm dialog
prior to posting to the server.
If the user clicks No then the dialog closes and no postback occurs. If they click Yes then the postback occurs.
<asp:TemplateColumn HeaderText="Edit and Delete Buttons">
<ItemTemplate>
<asp:imagebutton CommandName="btnEdit" id="btnEdit" runat="server" ImageUrl="~/img/edit.gif" ToolTip="Edit"></asp:imagebutton>
<span onclick="return confirm('Do you really want to delete this record from the system?')">
<asp:imagebutton CommandName="btnDelete" id="btnDelete"
runat="server" ImageUrl="~/img/delete.gif"
ToolTip="Delete"></asp:imagebutton>
</span>
</ItemTemplate>
</asp:TemplateColumn>

--
Joe Fallon

"rkbnair" <rk*****@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
Is there any way to display an image button instead of the traditional
Edit/Update/Cancel push button in a datagrid (with bound data)?


Nov 19 '05 #4
I'm sorry. I did that and it works now.

However, how to make the edit button functional?
i.e. makes the grid editable, provide an update button, and update the
database?

"Joe Fallon" wrote:
There is no source code error.
This is a copy of code from a fully functioning datagrid.

Ensure you copy all of the code including the <asp:TemplateColumn ...> tag
and place it in your datagrid. Change the name of the image and img folder
to your versions.
--
Joe Fallon

"rkbnair" <rk*****@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
The source code gives syntax errors.

Compiler does not recognize the imageurl etc.

"Joe Fallon" wrote:
Sure. Just use a Template column. This sample has 2 buttons in it - Edit and Delete.
Note the Delete is wrappen in a Span tag which pops up a Confirm dialog
prior to posting to the server.
If the user clicks No then the dialog closes and no postback occurs. If they click Yes then the postback occurs.
<asp:TemplateColumn HeaderText="Edit and Delete Buttons">
<ItemTemplate>
<asp:imagebutton CommandName="btnEdit" id="btnEdit" runat="server" ImageUrl="~/img/edit.gif" ToolTip="Edit"></asp:imagebutton>
<span onclick="return confirm('Do you really want to delete this record from the system?')">
<asp:imagebutton CommandName="btnDelete" id="btnDelete"
runat="server" ImageUrl="~/img/delete.gif"
ToolTip="Delete"></asp:imagebutton>
</span>
</ItemTemplate>
</asp:TemplateColumn>

--
Joe Fallon

"rkbnair" <rk*****@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
> Is there any way to display an image button instead of the traditional
> Edit/Update/Cancel push button in a datagrid (with bound data)?


Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Ester | last post: by
1 post views Thread by Phil_Cam | last post: by
2 posts views Thread by smokeyd | 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.