Column button to edit a record without going thru postback?

Discussion in 'ASP .Net' started by Randall Parker, Oct 29, 2005.

  1. Currently in an asp:DataGrid I have a column for bringing up an edit form on a
    particular row and that is done by a hyperlink as follows:

    <asp:TemplateColumn HeaderText="Edit Record">
    <ItemTemplate>
    <asp:HyperLink id="hyperlink1"
    NavigateUrl='<%# "EquipmentEdit.aspx?serial=" +
    DataBinder.Eval(Container, "DataItem.owner_serial_num") %>'
    Text='Edit'
    runat="server"/>
    </ItemTemplate>
    </asp:TemplateColumn>

    Instead of a text hyperlink I'd like a button appearance on that cell on each row so
    that the reader can see more clearly that clicking on it carries out an action. I
    figure there are two ways to do that:

    1) Make a button that does a submit and then have the CommandArgument carry both the
    action and the record id to use to open a different form. Then recognize in the
    Page_Load (or in some more appropriate server-side event?) that there is a postback
    and then look at the CommandArgument to parse out the action and the record id. Then
    to a Response.Redirect to that form with that argument.

    2) Make the button on the client form have an event to directly go to the destination
    page. I'm an ASP.Net novice and it is not clear to me how to do this.
    A) Is there an asp button control that is made for this purpose where one can
    give it a URL just as one can with the asp:HyperLink? If so, which control?
    B) Otherwise, which asp button control to use and do I just write a Javascript
    myself inside the <script> </script> tag? If so, how to get the string built up in
    the asp button control to pass to the Javascript to build the URL? I figure Ineed the
    DataBinder.Eval but am not clear where I'd use it in this case.
    Randall Parker, Oct 29, 2005
    #1
    1. Advertising

  2. Try this out. for the option A in the 2nd possibility.. Hope it is helpful.


    <asp:TemplateColumn HeaderText="Edit Record">
    <ItemTemplate>
    <INPUT type="button" value="Edit" onClick="window.open('<%#
    "EquipmentEdit.aspx?serial=" + DataBinder.Eval(Container, "DataItem.ID")
    %>','mywindow','width=400,height=200')">
    </ItemTemplate>
    </asp:TemplateColumn>

    --
    Regards,
    Sanjeevakumar Hiremath
    Proteans Software Solutions
    http://sharpnet.blogspot.com
    "Randall Parker" <NOtechieSPAMpundit_please@future_avoidjunk_pundit.com>
    wrote in message news:%23h$...
    > Currently in an asp:DataGrid I have a column for bringing up an edit form
    > on a particular row and that is done by a hyperlink as follows:
    >
    > <asp:TemplateColumn HeaderText="Edit Record">
    > <ItemTemplate>
    > <asp:HyperLink id="hyperlink1"
    > NavigateUrl='<%# "EquipmentEdit.aspx?serial=" +
    > DataBinder.Eval(Container, "DataItem.owner_serial_num") %>'
    > Text='Edit'
    > runat="server"/>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    > Instead of a text hyperlink I'd like a button appearance on that cell on
    > each row so that the reader can see more clearly that clicking on it
    > carries out an action. I figure there are two ways to do that:
    >
    > 1) Make a button that does a submit and then have the CommandArgument
    > carry both the action and the record id to use to open a different form.
    > Then recognize in the Page_Load (or in some more appropriate server-side
    > event?) that there is a postback and then look at the CommandArgument to
    > parse out the action and the record id. Then to a Response.Redirect to
    > that form with that argument.
    >
    > 2) Make the button on the client form have an event to directly go to the
    > destination page. I'm an ASP.Net novice and it is not clear to me how to
    > do this.
    > A) Is there an asp button control that is made for this purpose where
    > one can give it a URL just as one can with the asp:HyperLink? If so, which
    > control?
    > B) Otherwise, which asp button control to use and do I just write a
    > Javascript myself inside the <script> </script> tag? If so, how to get the
    > string built up in the asp button control to pass to the Javascript to
    > build the URL? I figure Ineed the DataBinder.Eval but am not clear where
    > I'd use it in this case.
    Sanjeevakumar Hiremath, Oct 31, 2005
    #2
    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. =?Utf-8?B?QW5u?=

    Edit datagrid row without postback

    =?Utf-8?B?QW5u?=, Jun 1, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    970
    =?Utf-8?B?RWx0b24gVw==?=
    Jun 1, 2005
  2. Bobby Edward

    EDM question - How insert record thru code?

    Bobby Edward, Sep 24, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    390
    Bobby Edward
    Sep 24, 2008
  3. Frank Kurka
    Replies:
    8
    Views:
    304
  4. THTB
    Replies:
    0
    Views:
    184
  5. Max Williams
    Replies:
    3
    Views:
    167
    Robert Klemme
    Jan 6, 2009
Loading...

Share This Page