R
Randall Parker
Currently in an aspataGrid 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.
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.