如何在gridview上更新时找到控件,而不在编辑模板中 [英] How to find the control while updating on gridview which is not in edit template

查看:57
本文介绍了如何在gridview上更新时找到控件,而不在编辑模板中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我想在网格视图上编辑时找到控件,其中控件不在编辑模板中,控件在itemtemplate中是否可以找到控件。



Actually i want to find the control while editing on grid view where the control is not in edit template the control is in itemtemplate is it possible to find the control.

protected void GridView1_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {


            }
}

推荐答案

嗨ntitish,



现在,请仅在您的记录数量少于30个奇数时尝试此操作。



Hi ntitish,

For now, please try this only if your records count is less than 30 odd.

int id = (int)GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value;

for (int i = 0; i < GridView1.Rows.Count; i++)
{
    if ((int)GridView1.DataKeys[i].Value == id)
    {
        Control ctrl = (Control)GridView1.Rows[i].FindControl("XXXXXXX");
    }
}





这样你可以获得控制权,但是如果你的记录数是多少太高了,因为使用了for循环,所以必须找出另一个选项。



谢谢,

Vamsi



This way you can get the control, but if your record count is too high, then will have to figure out another option due to the for loop used.

Thank you,
Vamsi


我们可以在gridview更新事件中找到所有控件我找到了特定的控件
we can find all controls in gridview updating event from that i finded the particular control


这篇关于如何在gridview上更新时找到控件,而不在编辑模板中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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