Datagrid / image button to edit

Discussion in 'ASP .Net' started by =?Utf-8?B?cmtibmFpcg==?=, Jan 25, 2005.

  1. Is there any way to display an image button instead of the traditional
    Edit/Update/Cancel push button in a datagrid (with bound data)?
     
    =?Utf-8?B?cmtibmFpcg==?=, Jan 25, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?cmtibmFpcg==?=

    Joe Fallon Guest

    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" <> wrote in message
    news:...
    > Is there any way to display an image button instead of the traditional
    > Edit/Update/Cancel push button in a datagrid (with bound data)?
     
    Joe Fallon, Jan 25, 2005
    #2
    1. Advertising

  3. 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" <> wrote in message
    > news:...
    > > Is there any way to display an image button instead of the traditional
    > > Edit/Update/Cancel push button in a datagrid (with bound data)?

    >
    >
    >
     
    =?Utf-8?B?cmtibmFpcg==?=, Jan 26, 2005
    #3
  4. =?Utf-8?B?cmtibmFpcg==?=

    Joe Fallon Guest

    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" <> wrote in message
    news:D...
    > 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" <> wrote in message
    > > news:...
    > > > Is there any way to display an image button instead of the traditional
    > > > Edit/Update/Cancel push button in a datagrid (with bound data)?

    > >
    > >
    > >
     
    Joe Fallon, Jan 26, 2005
    #4
  5. 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" <> wrote in message
    > news:D...
    > > 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" <> wrote in message
    > > > news:...
    > > > > Is there any way to display an image button instead of the traditional
    > > > > Edit/Update/Cancel push button in a datagrid (with bound data)?
    > > >
    > > >
    > > >

    >
    >
    >
     
    =?Utf-8?B?cmtibmFpcg==?=, Jan 26, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. San Diego Guy
    Replies:
    0
    Views:
    554
    San Diego Guy
    Aug 7, 2003
  2. Schultz
    Replies:
    3
    Views:
    570
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Feb 14, 2005
  3. Andreas Klemt
    Replies:
    0
    Views:
    313
    Andreas Klemt
    Oct 8, 2003
  4. Sharon McCarty
    Replies:
    0
    Views:
    255
    Sharon McCarty
    Nov 24, 2004
  5. Frank Kurka
    Replies:
    8
    Views:
    314
Loading...

Share This Page