Click here to Skip to main content
15,509,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i prevent my grid from resizing when clicking on the edit link button? i just need my gridview to be fixed..

note that when you click on the edit linkbutton 2 buttons appear : 1 for the update and 1 for the cancel and in the other cells textboxes appear to update the values that's why my grid is resizing.. how can i fix this?

that's my code on the editing event:

Protected Sub GridView1_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
GridView1.EditIndex = e.NewEditIndex
GridView1.DataSource = x.selectProfile
End Sub

and that's my asp code:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" onrowdatabound="GridView1_RowDataBound"
           AutoGenerateColumns="False" Width="604px"


                         <asp:CheckBox id="Select" runat="server" OnCheckedChanged="CheckedChanged" AutoPostBack="false"/>
                         <asp:LinkButton  ID="idedit" CommandName="Edit" CausesValidation="true" runat="server"
                               ToolTip="Edit"  Text="Edit"/>
                         <asp:LinkButton ID="selectID" CommandName="Select" CausesValidation="true" runat="server"
                               ToolTip="Select"  Text="Select" />


any help would be much appreciated

thank you in advance

1 solution

Try replace width size to 604 px to 100%

Or you can also check how i did it

its aspx page where i have initialized Grid View and Bind it with my data source & some action added from properties window like onrowediting, onrowupdating, onrowcancelingedit...!!   

<asp:gridview id="GridView1" runat="server" autogeneratecolumns="false" xmlns:asp="#unknown">
            DataKeyNames="UserId" onrowediting="GridView1_RowEditing" 
<asp:templatefield headertext="Name">
            <asp:label id="lblName" runat="server" text="<%# Eval("Name") %>"></asp:label>
            <asp:textbox id="txtName" runat="server" text="<%# Eval("Name") %>"></asp:textbox>

<asp:templatefield headertext="Edit">
            <asp:linkbutton id="lnkEdit" runat="server" commandname="Edit">Edit</asp:linkbutton>
            <asp:linkbutton id="lnkUpdate" runat="server" commandname="Update">Update</asp:linkbutton>
            <asp:linkbutton id="lnkCancel" runat="server" commandname="Cancel">Cancel</asp:linkbutton>

Share this answer
pradippatel99 23-Aug-13 9:57am    
just use width in percentage.
it will work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900