访问tabpannel内Gridview内的文本框. [英] accessing Text Box inside Gridview inside tabpannel.

查看:101
本文介绍了访问tabpannel内Gridview内的文本框.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问网格视图内的文本框值,并且该网格视图位于选项卡面板中.


以下是我的代码,在其中获得了选项卡面板名称,但无法访问网格视图和文本框.

I want to access Text box value inside grid view and that grid view is in tabpannel.


Following is my code, where I got tab panel name but not able to access grid view and text box.

string str = null;
        AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)TabContainer1;
        foreach (object obj in container.Tabs)
        {
            if (obj is AjaxControlToolkit.TabPanel)
            {
                AjaxControlToolkit.TabPanel tabPanel = (AjaxControlToolkit.TabPanel)obj;
                //Code for tab panel header text
                str = tabPanel.HeaderText.Trim();
                foreach (object ctrl in tabPanel.Controls)
                {
                    if (ctrl is Control)
                    {
                        Control c = (Control)ctrl;
                        foreach (object innerCtrl in c.Controls)
                        {
                            if (innerCtrl is System.Web.UI.WebControls.GridView)
                            {
                             //control didn't enter this block...   
                             int k = 0;                                
                            }
                        }
                    }
                }
            }
        }



请在高级方面帮助我.谢谢....



please help me thanx in advanced....

推荐答案


首先让我告诉您一件事,您可以通过其ID直接访问gridview.不在选项卡面板中时.您可以通过使用其ID(例如GridView1)直接调用选项卡面板的所有控件.

现在的问题是您的文本框在gridview中的哪里.
如果您的文本框位于项目模板中,则可以通过以下方式访问它:

Hi,
First of all let me tell you one thing that your can directly access your gridview by it''s id. No matters when it is in tab panel. All the controls of tab panel you can access directly by calling it using it''s id like GridView1.

Now the problem is where is your textbox inside gridview.
If your textbox is in item template then you can access it by using this:

//Updated Looping through the controls of tabcontainer
foreach(Control s in tabContainer1.Controls) 
{
    // If control is gridview
    if (s is GridView) { 
        //Looping through gridview
        foreach (GridViewRow dr in gridview.Rows)
        {
            //Finding the Textboxes
            TextBox txt=(TextBox)dr.FindControl("YourTextBoxID");
            // Do your work with txt..
        }
    }
}


请参考 [


Refer this[^] for more information.


--Amit


这篇关于访问tabpannel内Gridview内的文本框.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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