问题描述
如何在点击编辑链接按钮时阻止我的网格调整大小?我只需要修复gridview ..
请注意,当您单击编辑链接按钮时,会出现2个按钮:1表示更新,1表示取消和按其他单元格文本框似乎更新值,这就是我的网格调整大小的原因..我该如何解决这个问题?
这是我的代码关于编辑事件:
受保护的子GridView1_RowEditing(发送者为对象,e为System.Web.UI.WebControls.GridViewEditEventArgs)处理GridView1.RowEditing
GridView1.EditIndex = e.NewEditIndex
GridView1.DataSource = x.selectProfile
GridView1.DataBind()
End Sub
这是我的asp代码:
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:
<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
推荐答案
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"
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>
这篇关于单击LinkButton时阻止GridView调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!