GridView控件采取行 [英] GridView take a Row

查看:134
本文介绍了GridView控件采取行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

净4和C#。

我有一个GridView,我想采取行时在编辑模式下在我的code和找到控制。

下面我code,但不工作,只需要在第一行的GridView的。

任何想法?

 保护无效uxManageSlotsDisplayer_RowDataBound(对象发件人,GridViewRowEventArgs E)
{    开关(e.Row.RowType)
    {
        案例DataControlRowType.DataRow:        //将排在编辑模式下不工作PROEPRLY
        如果(e.RowState == DataControlRowState.Edit)
        {
            标签MYTEST =(标签)e.Row.FindControl(uxTest);
        }
        打破;    }

我的code范例:
的GridView行编辑模式

解决方案:
在阅读完之后:<一href=\"http://stackoverflow.com/questions/833490/asp-net-3-5-gridview-row-editing-dynamic-binding-to-a-dropdownlist\">ASP.NET 3.5 GridView控件 - 行编辑 - 动态绑定到一个DropDownList

 保护无效uxList_RowDataBound(对象发件人,GridViewRowEventArgs E)
    {
        如果(e.Row.RowType == DataControlRowType.DataRow&放大器;&安培;
                (e.Row.RowState&安培; DataControlRowState.Edit)== DataControlRowState.Edit)
        {
            //在这里,你会得到你需要像控制:
            标签(DL)=(标签)e.Row.FindControl(uxLblTest);
            dl.Text =XXXXXXXXXXXXX;
        }
    }


解决方案

编辑:
增加了对检查的DataRow

 如果(e.Row.RowType == DataControlRowType.DataRow&放大器;&安培; e.Row.RowState == DataControlRowState.Edit)

而不是

 如果(e.RowState == DataControlRowState.Edit)

net 4 and c#.

I have a GridView, I would like take a Row when in Edit Mode in my code and find a control.

Here my code, but does not work, it takes only the first row for the GridView.

Any ideas?

protected void uxManageSlotsDisplayer_RowDataBound(object sender, GridViewRowEventArgs e)
{

    switch (e.Row.RowType)
    {
        case DataControlRowType.DataRow:

        // Take Row in Edit Mode DOES NOT WORK PROEPRLY
        if (e.RowState == DataControlRowState.Edit)
        {
            Label myTest = (Label)e.Row.FindControl("uxTest");
        }
        break;

    }

MY CODE EXAMPLES: GridView row in edit mode

SOLUTIONS: After reading this: ASP.NET 3.5 GridView - row editing - dynamic binding to a DropDownList

        protected void uxList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow &&
                (e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
        {
            // Here you will get the Control you need like:
            Label dl = (Label)e.Row.FindControl("uxLblTest");
            dl.Text = "xxxxxxxxxxxxx";
        }
    }

解决方案

Edit: Added check for DataRow

 if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState == DataControlRowState.Edit)

instead of

 if (e.RowState == DataControlRowState.Edit)

这篇关于GridView控件采取行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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