Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid / image button to edit

Reply
Thread Tools

Datagrid / image button to edit

 
 
=?Utf-8?B?cmtibmFpcg==?=
Guest
Posts: n/a
 
      01-25-2005
Is there any way to display an image button instead of the traditional
Edit/Update/Cancel push button in a datagrid (with bound data)?
 
Reply With Quote
 
 
 
 
Joe Fallon
Guest
Posts: n/a
 
      01-25-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is there any way to display an image button instead of the traditional
> Edit/Update/Cancel push button in a datagrid (with bound data)?



 
Reply With Quote
 
 
 
 
=?Utf-8?B?cmtibmFpcg==?=
Guest
Posts: n/a
 
      01-26-2005
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Is there any way to display an image button instead of the traditional
> > Edit/Update/Cancel push button in a datagrid (with bound data)?

>
>
>

 
Reply With Quote
 
Joe Fallon
Guest
Posts: n/a
 
      01-26-2005
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" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Is there any way to display an image button instead of the traditional
> > > Edit/Update/Cancel push button in a datagrid (with bound data)?

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?cmtibmFpcg==?=
Guest
Posts: n/a
 
      01-26-2005
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" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > Is there any way to display an image button instead of the traditional
> > > > Edit/Update/Cancel push button in a datagrid (with bound data)?
> > >
> > >
> > >

>
>
>

 
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
Snapshot restraint - edit, edit, edit Alan Browne Digital Photography 24 05-10-2005 10:15 PM
Snapshot restraint - edit, edit, edit Patrick Digital Photography 0 05-06-2005 10:53 PM
Would like to load a datagrid already in edit mode instead of having the user click the edit button Frank Kurka ASP .Net Datagrid Control 8 04-29-2005 09:33 AM
Edit All Function for DataGrid, and Moving the Edit Function in a DataGrid Schultz ASP .Net 3 02-14-2005 04:47 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