-
November 28th, 2008, 02:55 AM
#1
Possible to move [Edit] button on the RIGHT of a GridView row? (ASP.NET VS2008 C#)
I have an .aspx webpage that contains a GridView (gvInfo), the GridView itself is edit'able (as shown below) by enabling "AutoGenerateEditButton=true", this allows for me to display the EDIT button on the left side of the GridView so that users can select it and then edit the contents of the row.
But, by default the EDIT button is located on the LEFT of the rows, and with the design of my website it looks very odd, I would much prefer - if it is possible - to display the EDIT button on the RIGHT side of the rows - does anyone have a clue if this is possible and if so how it could be accomplished?
Code:
<asp:GridView ID="gvInfo" runat="server" Height="99px" CellSpacing="5" AutoGenerateColumns="False" CellPadding="2"
AllowPaging="False"
AutoGenerateEditButton="true" OnRowEditing="gvRegularDosage_RowEditing"
OnRowCancelingEdit="gvRegularDosage_RowCancelingEdit" OnRowUpdating="gvRegularDosage_RowUpdating"
EmptyDataText="No records found" >
<Columns>
...
...
</Columns>
</asp:GridView>
Any help would be greatly appreciated.
Thanks,
-
November 28th, 2008, 06:21 AM
#2
Re: Possible to move [Edit] button on the RIGHT of a GridView row? (ASP.NET VS2008 C#
Instead of AutoGenerateEditButton="true", add a column of type CommandField
Code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>
-
December 1st, 2008, 06:44 AM
#3
Re: Possible to move [Edit] button on the RIGHT of a GridView row? (ASP.NET VS2008 C#
Hi, You can also do in the following way by using a linkbutton/button as an item in the template field and then use the row command method to perform the editing role or whatever is required. You can just use a template field in the following way:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" onRowCommand="RowCommand">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:LinkButton ID="LinkButton1" runat="server" Text="Edit"></asp:LinkButton>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>
and you can use the rowcommand method for describing the functionality.
I hope this would solve your problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|