Click here to Skip to main content
15,880,796 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
GridView1.DataBind()
End Sub

and that's my asp code:

XML
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" onrowdatabound="GridView1_RowDataBound"
           AutoGenerateColumns="False" Width="604px"
           DataKeyNames="id,firstname,lastname,adress,email,telephone,birthday">

           <Columns>
           <asp:TemplateField>

                   <ItemTemplate>
                         <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" />
                       </ItemTemplate>

                   <EditItemTemplate>




any help would be much appreciated

thank you in advance
Posted

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.NET
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="false" xmlns:asp="#unknown">
            DataKeyNames="UserId" onrowediting="GridView1_RowEditing" 
            onrowupdating="GridView1_RowUpdating" 
            onrowcancelingedit="GridView1_RowCancelingEdit">
        <columns>
<asp:templatefield headertext="Name">
        <itemtemplate>
            <asp:label id="lblName" runat="server" text="<%# Eval("Name") %>"></asp:label>
        </itemtemplate>
        <edititemtemplate>
            <asp:textbox id="txtName" runat="server" text="<%# Eval("Name") %>"></asp:textbox>
        </edititemtemplate>
        </asp:templatefield>

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

        </columns>
        </asp:gridview>
 
Share this answer
 
v3
Comments
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