使用三层gridview的行删除事件删除问题 [英] problem in deleting using row deleting event of gridview using three tier..

查看:73
本文介绍了使用三层gridview的行删除事件删除问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在gridview中创建删除行..

使用三层...
我在从gridview获取所需的行时遇到了错误.

i am trying to create a delete the row in gridview..

using three tier...
i am having error in this getting the requied line from gridview.

<pre lang="c#">

GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
        Label Username = (Label)row.FindControl("UserName"); // problem in these lines..pls give me any alternate of that to sort out my problem
       


        // instantiate BAL
        Businesslayer pBAL = new Businesslayer();
        try
        {
            pBAL.Delete(Username);

            lblMessage.Text = "Record Deleted Successfully.";
        }
        catch (Exception ee)
        {
            lblMessage.Text = ee.Message.ToString();
        }
        finally
        {
            pBAL = null;
        }

       // GridView1.EditIndex = -1;
        // Refresh the list
        BindGrid();
    }




错误是..




the errors are ..

Error	1	The best overloaded method match for ''Businesslayer.Delete(string)'' has some invalid arguments	





Error	2	Argument ''1'': cannot convert from ''System.Web.UI.WebControls.Label'' to ''string''	



帮助我解决问题..
我如何访问特定类型的列中的值,该列是基于字符串的类型,因此可以删除整行..



help me to sort out the problem..
how can i access the value in a particular column which is of string type on the bases of which i can delete entire row..

推荐答案

了解您正在使用的代码和控件.该错误非常清楚地告诉您该方法采用字符串,而传递给它的不是字符串.

用户名是一个Label CONTROL,您需要Text属性来获取存储在其中的字符串.
It would help if you actual understood the code and controls you are using. The error very clearly tells you the method take a string and what you are passing to it is not a string.

Username is a Label CONTROL you need the Text property to get the string that is stored in it.


这篇关于使用三层gridview的行删除事件删除问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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