如何删除Gridview Row [英] How to delete Gridview Row

查看:85
本文介绍了如何删除Gridview Row的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从 GridView 中删除​​行。首先,我必须检查 CheckBox ,然后单击 GridView 中的删除按钮。这不会影响数据库。该行将从 GridView 中删除​​。



我该怎么做?请帮帮我。

解决方案

在这里参考



inserteditupdate-and-delete



Add-Edit-update-Delete-gridview

你能显示你的代码吗?



或者你可以参考这个片段



< pre lang =c#> if (checkedbox1.Checked)
{
GridView1.Rows.Remove(TheSelectedRow);
GridView1.DataSource = // 调用数据绑定
}


在网格上应用for循环。从网格中找到复选框控件,如下所示: -

   int  i =  0 ; i< grdView.rows.count,i ++)>  
{
CheckBox chkSel =(CheckBox)grdView.Rows [i] .FindControl( chkselect);
if (chkSel。 checked == true
grdView.Rows.RemoveAt(i);
}





试一试。


I have to delete row from GridView. First I have to check the CheckBox and then click Delete button in GridView. This will not affect database. The row will be deleted from GridView.

How can I do this? Please help me.

解决方案

refer here

inserteditupdate-and-delete

Add-Edit-update-Delete-gridview


can you show your code?

or you can refer to this snippets

if (checkedbox1.Checked)
{
 GridView1.Rows.Remove(TheSelectedRow);
 GridView1.DataSource=//Call the Databinding
}


Apply a for loop on the grid. Find the check box control from the grid like this:-

for(int i=0;i<grdView.rows.count,i++)>
     {
       CheckBox chkSel=(CheckBox)grdView.Rows[i].FindControl("chkselect");
       if(chkSel.checked==true)
         grdView.Rows.RemoveAt(i);
     }



Give it a try.


这篇关于如何删除Gridview Row的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆