473,320 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Column button to edit a record without going thru postback?

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.
Nov 19 '05 #1
1 1607
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:%2****************@tk2msftngp13.phx.gbl...
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.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Samantha Smit | last post by:
Hi, I am trying to create a simple asp page that has one command button that updates a database. The URL of the page is like this: http://MyServer.com/Update.asp?UserName=Tom My asp code is...
2
by: localhost | last post by:
When I go into Edit mode on a datagrid, I would like to add a single column to the edited row and display a hyperlink. If I use the code below, I get a delete linkbutton in every row, when I only...
5
by: J McD | last post by:
Hi I have a DataGrid with an ImageButton column. When I click on an imagebutton I get a postback but it doesn't run the OnImgBtnClick method. I can actually comment out the line where I add this...
5
by: | last post by:
Hi all, Has anyone been able to write some custom javascript on the onclick event of submit button to do certain things like disable submit button, only submit form once etc. This was a breeze...
2
by: pradeep_TP | last post by:
Hello world, I have a simple datagrid on asp.net web form , in which I am showing a single button column called EDIT. The code in the .aspx files for the same is as below. ...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
6
by: djjohnst | last post by:
I am creating a program that will list program times for people who visit our website. Users can login create, edit, delete a program. These dump into a database. The ASP webpage then reads from...
8
by: MAX2006 | last post by:
Hi, I am doing some client side javascipt work. I have a handler for window.onUnload event and within the code; I need to know the name of the asp.net button caused the postback. How can I do...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.