本文介绍了在checkboxlist上调用gridview按钮单击事件选择索引已更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个复选框列表和一个gridview。 Gridview:= < ; asp:GridView ID = grdColumns runat = server AutoGenerateColumns = False 宽度 = 800px ShowFooter = true CssClass = gridtable1 > < 列 > < asp:TemplateField HeaderText = 删除 > < ItemTemplate > < asp:按钮 runat = server ID = btnRemove 文字 = 删除 OnClick = btnRemove_Click / > < / ItemTemplate > < / asp:TemplateField > < /列 > < ; / asp:GridView > 如果我选中/取消选中复选框list.i中的任何项目,我需要在gridview中添加和删除动态行。在btnremove_click中写入代码以删除动态行。 当我点击删除按钮它工作正常。 现在我想调用此按钮点击事件对所选索引更改为checkboxlist,以便这样做我可以删除我想从gridview中的多行删除的特定行。但是它给出了错误。如何实现这个任务?有没有其他方法可以这样做? 帮我... protected void btnRemove_Click( object sender,EventArgs e) { GridViewRow gvRow =(GridViewRow)(sender as Control).Parent.Parent; int rindex = gvRow.RowIndex; //剩余代码到此处 } 解决方案 只需直接从数据库添加和删除并重新绑定gridview。 或 您可以使用事件处理程序调用 上的按钮单击事件 protected void Page_Load(object sender,EventArgs e) { CheckboxID.Change + = new EventHandler(this.btnRemove_Click); } i have a checkbox list and a gridview.Gridview:=<asp:GridView ID="grdColumns" runat="server" AutoGenerateColumns="False" Width="800px" ShowFooter="true" CssClass="gridtable1"> <Columns><asp:TemplateField HeaderText="Remove"> <ItemTemplate> <asp:Button runat="server" ID="btnRemove" Text="Remove" OnClick="btnRemove_Click" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>I need to add and remove a dynamic row from gridview on if i checked/unchecked any item of checkbox list.i have code written inside btnremove_click to remove dynamic row.When i click on remove button it works fine.now i want to call this button click event on selected index changed of checkboxlist so that a so that i could delete a paricular row which i want to delete from multiple rows in gridview. But it gives error.How to achieve this task?Is there any other way to do so?Help Me...protected void btnRemove_Click(object sender, EventArgs e) { GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent; int rindex = gvRow.RowIndex; //remaining code goes here } 解决方案 Simply you can add and remove directly from database and rebind the gridview.OrYou can use the event handler to call the button click event on the protected void Page_Load(object sender, EventArgs e) { CheckboxID.Change += new EventHandler(this.btnRemove_Click );} 这篇关于在checkboxlist上调用gridview按钮单击事件选择索引已更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-13 04:18