asp.net gridview editindex [英] asp.net gridview editindex
本文介绍了asp.net gridview editindex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是asp.net的新手。我有一个带编辑按钮的gridview。
当我第一次点击该按钮时没有任何反应。但下次上一行被选中。请帮帮我。
谢谢
解决方案
我遇到了同样的问题。问题出在你的datatbind逻辑上。
请检查您的代码是否存在以下问题:
1.网格数据绑定逻辑必须在Page_Load中事件。
2.它应该包含在if(!Page.IsPostBack){//数据绑定逻辑这里; }
使用这个
< 列 >
< ; asp:TemplateField ItemStyle-Width = 90px >
< EditItemTemplate >
< asp:ImageButton ID = imgbtnUpdate CommandName = 更新 runat = server < span class =code-attribute> ImageUrl = 〜/ Images / update.png
工具提示 = 更新 / >
< span class =code-keyword>< asp:ImageButton ID = imgbtnCancel runat = server CommandName = < span class =code-keyword>取消 ImageUrl = 〜/ Images / Cancel.png
< span class =code-attribute> < span class =code-attribute> < span class =code-attribute> 工具提示 = 取消 / >
< / EditItemTemplate >
< ItemTemplate >
< asp:ImageButton ID = imgbtnEdit CommandName = 编辑 < span class =code-attribute> runat = server ImageUrl = 〜/ Images / Edit.png
< span class =code-attribute> 工具提示 = 编辑 / >
< asp:ImageButton ID = imgbtnDelete CommandName = 删除 文字 = 编辑 runat = server < span class =code-attribute>
< span class =code-attribute> < span class =code-attribute> ImageUrl = 〜/ Images / delete.png 工具提示 = 删除 高度 = 20px 宽度 = 20px / >
< / ItemTemplate >
< FooterTemplate < span class =code-keyword>>
< asp:ImageButton ID = imgbtnAdd runat = server ImageUrl = 〜/ Images / AddNewitem.png
< span class =code-attribute> < span class =code-attribute> CommandName = AddNew / >
< / FooterTemplate >
< / asp:TemplateField > < /跨度>
i am new to asp.net. i have a gridview with edit button.
when i click that button first time nothing happens. but next time previous row get selected. please help me out.
thanks
解决方案
I encountered the same issue .The problem is with your datatbind logic.
Please check your code for these issues:
1. The grid databind logic must be in Page_Load event.
2. It should be enclosed inside if(!Page.IsPostBack) { //databind logic here; }
use this
<Columns> <asp:TemplateField ItemStyle-Width="90px"> <EditItemTemplate> <asp:ImageButton ID="imgbtnUpdate" CommandName="Update" runat="server" ImageUrl="~/Images/update.png" ToolTip="Update" /> <asp:ImageButton ID="imgbtnCancel" runat="server" CommandName="Cancel" ImageUrl="~/Images/Cancel.png" ToolTip="Cancel" /> </EditItemTemplate> <ItemTemplate> <asp:ImageButton ID="imgbtnEdit" CommandName="Edit" runat="server" ImageUrl="~/Images/Edit.png" ToolTip="Edit" /> <asp:ImageButton ID="imgbtnDelete" CommandName="Delete" Text="Edit" runat="server" ImageUrl="~/Images/delete.png" ToolTip="Delete" Height="20px" Width="20px" /> </ItemTemplate> <FooterTemplate> <asp:ImageButton ID="imgbtnAdd" runat="server" ImageUrl="~/Images/AddNewitem.png" CommandName="AddNew" /> </FooterTemplate> </asp:TemplateField>
这篇关于asp.net gridview editindex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文