三个级联下拉菜单 [英] Three Cascading dropdowns

查看:115
本文介绍了三个级联下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为3个下拉列表编写了代码.在填充方法中,第2个下拉列表采用第3个下拉列表值. 1st和3rd正确服用.
它在for循环中正确执行.其执行值是上次执行值的3倍

I wrote code for 3 dropdown list. In populate method 2nd dropdown takes 3rd dropdown value. 1st one and 3rd one taking correctly.
It''s executing correctly in for loop. its executing 3 times its taking values for last time executing

foreach (CCBusiness.AttributeValues obja in objval)
                    {
                        if (obja != null)
                        {
                            attributeID = obja.AttributeID;
                            validation = obja.Validation;
                            for (int t = 0; t < tblAttributeView.Rows.Count; t++)
                            {
                                if (obja.DataType == "ip")
                                    
                                {
                                    
                                    for (int s = 0; s < 4; s++)
                                    {
                                        controlID = "ATT" + Convert.ToString(CurrentIndex ) + Convert.ToString(attributeID) + "-" + (s + 1);
                                        Control c = tblAttributeView.Rows[t].FindControl(controlID);
                                        Control c1 = tblAttributeView.Rows[t].FindControl(controlID);
                                        Control c2 = tblAttributeView.Rows[t].FindControl(controlID);
                                        if (c is System.Web.UI.WebControls.TextBox)
                                        {
                                            TextBox txt = (TextBox)c;
                                            txt.Text = SplitIpAddress(validation)[s];
                                        }
                                        //25/03
                                        //Control c1 = tblAttributeView.Rows[t].FindControl(controlID);
                                        if (c1 is System.Web.UI.WebControls.TextBox)
                                        {
                                            TextBox txt = (TextBox)c1;
                                            txt.Text = SplitIpAddress(validation)[s];
                                        }
                                        //Control c2 = tblAttributeView.Rows[t].FindControl(controlID);
                                        if (c2 is System.Web.UI.WebControls.TextBox)
                                        {
                                            TextBox txt = (TextBox)c2;
                                            txt.Text = SplitIpAddress(validation)[s];
                                        }
                                        //25/03
                                    }
                                }
                                else
                                {
                                    
                                    
                                    if (CCBusiness.ProductClass.ProductTypes.Package == (CCBusiness.ProductClass.ProductTypes)productType)
                                        controlID = "ATT" + Convert.ToString(CurrentIndex) +  "ddlTemplate";
                                    else
                                        controlID = "ATT" + Convert.ToString(CurrentIndex) + Convert.ToString(attributeID);
                                    //..........
                                    Control c = tblAttributeView.Rows[t].FindControl(controlID);
                                    if (c is System.Web.UI.WebControls.DropDownList)
                                    {
                                        DropDownList ddl = (DropDownList)c;
                                        ddl.SelectedValue = validation;
                                        if (validation == "")
                                            ddl.SelectedIndex = 0;
                                    }
                                    else if (c is System.Web.UI.WebControls.TextBox)
                                    {
                                        TextBox txt = (TextBox)c;
                                        txt.Text = validation;
                                    }
                                    else if (c is DateTimeSelector)
                                    {
                                        DateTimeSelector dts = (DateTimeSelector)c;
                                        if (ConvertDate(validation) != "")
                                            dts.Date = string.Format("{0:dd MMM yy}", Convert.ToDateTime(ConvertDate(validation)));
                                    }
                                    //................
                                    //////........
                                    if (CCBusiness.ProductClass.ProductTypes.Package == (CCBusiness.ProductClass.ProductTypes)productType)
                                        controlID = "ATT" + Convert.ToString(CurrentIndex) + "ddlcontract_term";
                                    else
                                        controlID = "ATT" + Convert.ToString(CurrentIndex) + Convert.ToString(attributeID);
                                    //..............
                                    Control c1 = tblAttributeView.Rows[t].FindControl(controlID);
                                    if (c1 is System.Web.UI.WebControls.DropDownList)
                                    {
                                        DropDownList ddl = (DropDownList)c1;
                                        ddl.SelectedValue = validation;
                                        //ddl.SelectedItem.Text = validation;
                                        if (validation == "")
                                            ddl.SelectedIndex = 0;
                                    }
                                    else if (c1 is System.Web.UI.WebControls.TextBox)
                                    {
                                        TextBox txt = (TextBox)c1;
                                        txt.Text = validation;
                                    }
                                    else if (c1 is DateTimeSelector)
                                    {
                                        DateTimeSelector dts = (DateTimeSelector)c1;
                                        if (ConvertDate(validation) != "")
                                            dts.Date = string.Format("{0:dd MMM yy}", Convert.ToDateTime(ConvertDate(validation)));
                                    }
                                    //////.............
                                    if (CCBusiness.ProductClass.ProductTypes.Package == (CCBusiness.ProductClass.ProductTypes)productType)
                                        controlID = "ATT" + Convert.ToString(CurrentIndex) + "ddlContract_unit";
                                    else
                                        controlID = "ATT" + Convert.ToString(CurrentIndex) + Convert.ToString(attributeID);
                                    //..................
                                    Control c2 = tblAttributeView.Rows[t].FindControl(controlID);
                                    if (c2 is System.Web.UI.WebControls.DropDownList)
                                    {
                                        DropDownList ddl = (DropDownList)c2;
                                        ddl.SelectedValue = validation;
                                        //ddl.SelectedItem.Text = validation;
                                        if (validation == "")
                                            ddl.SelectedIndex = 0;
                                    }
                                    else if (c2 is System.Web.UI.WebControls.TextBox)
                                    {
                                        TextBox txt = (TextBox)c2;
                                        txt.Text = validation;
                                    }
                                    else if (c2 is DateTimeSelector)
                                    {
                                        DateTimeSelector dts = (DateTimeSelector)c2;
                                        if (ConvertDate(validation) != "")
                                            dts.Date = string.Format("{0:dd MMM yy}", Convert.ToDateTime(ConvertDate(validation)));
                                    }
                                }

推荐答案

查看此链接

http://www.obout.com/Interface/aspnet_integration_cascading.aspx [
see this link

http://www.obout.com/Interface/aspnet_integration_cascading.aspx[^]


这篇关于三个级联下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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