I am having two dropdownlists that are interrelated, in which one is vertical ddl and the other department ddl in a grid view
if we select the vertical ddl then corresponding departments have to appear in department ddl.

I've written the code like this
In footer of gridview i successful managed to embed the two dropdowns,
But when edit mode i am not able to identify the row index

Note: i am using onselected index changed event in vertical ddl in both footer and edit mode,
but i am not able to get the row index of gridview.

here is example code for footer:

protected void Onverticalselection(object sender,EventArgs e) //onselectedindexchanged event of vertical ddl
    {
        objBW= new BWizard_demomast();
        dsmdemo=new DataSet();//ekkada datatable kudha use cheyachu
        
        string Flag;
        Vertical = string.Empty;
        Department = string.Empty;
        
        DropDownList ddlvert = new DropDownList();
        ddlvert = (DropDownList)gdviw1.FooterRow.FindControl("ddlvertF");

        DropDownList ddldepart = new DropDownList();
        ddldepart = (DropDownList)gdviw1.FooterRow.FindControl("ddldepartF");
        
        
        Flag = ((DropDownList)gdviw1.FooterRow.FindControl("ddlvertF")).SelectedValue;
        
        dsmdemo = objBW.GetdropdownsBW(Flag,Vertical,Department);
        ddldepart.Items.Clear(); //previous selected items ni eliminate cheyadaniki
        if (dsmdemo.Tables.Count > 0)//ekkada datatable use cheste tables[0].rows.count ani vadali
        {
            if (dsmdemo.Tables[0].Rows.Count > 0)
            {
                ddldepart.DataSource = dsmdemo.Tables[0];
                ddldepart.DataValueField = dsmdemo.Tables[0].Columns["LOCATION_VALUE"].ColumnName;
                ddldepart.DataTextField = dsmdemo.Tables[0].Columns["LOCATION_CODE"].ColumnName;
                ddldepart.DataBind(); 
            }
        }
        ddldepart.Items.Insert(0, new ListItem("Select", ""));
        
    }

how can we identify the control in the edit mode.


please do needful at the earliest, i am working on a project

>how can we identify the control in the edit mode.

Check the EditIndex property value.

I am having two dropdownlists that are interrelated, in which one is vertical ddl and the other department ddl in a grid view
if we select the vertical ddl then corresponding departments have to appear in department ddl.

I've written the code like this
In footer of gridview i successful managed to embed the two dropdowns,
But when edit mode i am not able to identify the row index

Note: i am using onselected index changed event in vertical ddl in both footer and edit mode,
but i am not able to get the row index of gridview.

here is example code for footer:

protected void Onverticalselection(object sender,EventArgs e) //onselectedindexchanged event of vertical ddl
    {
        objBW= new BWizard_demomast();
        dsmdemo=new DataSet();//ekkada datatable kudha use cheyachu
        
        string Flag;
        Vertical = string.Empty;
        Department = string.Empty;
        
        DropDownList ddlvert = new DropDownList();
        ddlvert = (DropDownList)gdviw1.FooterRow.FindControl("ddlvertF");

        DropDownList ddldepart = new DropDownList();
        ddldepart = (DropDownList)gdviw1.FooterRow.FindControl("ddldepartF");
        
        
        Flag = ((DropDownList)gdviw1.FooterRow.FindControl("ddlvertF")).SelectedValue;
        
        dsmdemo = objBW.GetdropdownsBW(Flag,Vertical,Department);
        ddldepart.Items.Clear(); //previous selected items ni eliminate cheyadaniki
        if (dsmdemo.Tables.Count > 0)//ekkada datatable use cheste tables[0].rows.count ani vadali
        {
            if (dsmdemo.Tables[0].Rows.Count > 0)
            {
                ddldepart.DataSource = dsmdemo.Tables[0];
                ddldepart.DataValueField = dsmdemo.Tables[0].Columns["LOCATION_VALUE"].ColumnName;
                ddldepart.DataTextField = dsmdemo.Tables[0].Columns["LOCATION_CODE"].ColumnName;
                ddldepart.DataBind(); 
            }
        }
        ddldepart.Items.Insert(0, new ListItem("Select", ""));
        
    }

how can we identify the control in the edit mode.


please do needful at the earliest, i am working on a project

See this link
http://mikepope.com/blog/fun/cascadingdropdowns_gridview.aspx

click on "Source (approximately) here." to view the code on that page

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.