网格视图reg中的错误 [英] error in grid view reg

查看:113
本文介绍了网格视图reg中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用以下代码从网格视图中检索值到标签


Hi,

I use following code to retrive the values from grid view to label


ds = autosql.ShowDatas("SELECT * FROM Fax_Tablename");
            if (ds.Tables[0].Rows.Count > 0)
            {
                lbl_id.Text = ds.Tables[0].Rows[0]["cmid"].ToString();

            }




我在网格视图中选择了GridView1_RowDeleting命令以删除选定的行
作为查询




den i selected the GridView1_RowDeleting command in grid view to delete the selected row
as query

delete from Fax_tablename where cid=''" + lbl_id.Text + "'' "



如果我在网格视图中选择删除按钮,则会删除数据库中的第一个值,因为我正在使用



if i select the delete button in grid view it deletes the first value in database since i am using

ds.Tables[0].Rows.Count




但我的问题是

单击删除按钮后,我需要在网格视图中删除选定的行



等待您的回应
在此先感谢


问候,
gowtham




but my problem is

i need to delete the selected row in grid view on clicking the delete button



waiting for ur responces
thanks in advance


regards,
gowtham

推荐答案

是的,我得到的解决方案为

< pre>受保护的void GridView1_DeleteCommand(对象源,DataGridCommandEventArgs e)
{
int indx = e.Item.ItemIndex;
lbl_id.Text = GridView1.Items [indx] .Cells [1] .Text; //根据表格的主键更改单元格名称,
}</pre>



< pre>从Fax_tablename中删除,其中cid =''"+ lbl_id.Text +"''</pre>



问候,
gowtham
Ya, i got the solution as

<pre>protected void GridView1_DeleteCommand(object source, DataGridCommandEventArgs e)
{
int indx = e.Item.ItemIndex;
lbl_id.Text = GridView1.Items[indx].Cells[1].Text; //Change the cell name based on the primary key of the table,
}</pre>



<pre>delete from Fax_tablename where cid=''" + lbl_id.Text + "'' "</pre>



regards,
gowtham


这篇关于网格视图reg中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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