Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,
I want to ask that I used three dropdown in gridview

Project,Module and Form I called all dropdown's in rowdatabound,I have to check dependency like when I select Project all Module inside project should come in dropdown Module all process will happen in gridview Please guide me how could I show dependency

Please guide me


my code is

C#
protected void grdDaily_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           //Projects values in drodpown
           dt = DelayworkReport.fillProjects();
           ListItem lst = new ListItem("Select", "0");
           DropDownList list = (DropDownList)e.Row.Cells[5].FindControl("ddlProject");
           list.DataTextField = "ProjectABR";
           list.DataValueField = "ProjectId";
           list.DataSource = dt;
           list.DataBind();
           list.AutoPostBack = true;
           list.Items.Insert(0, lst);

           //Module Values in dropdown
           dt = DelayworkReport.fillModule(Convert.ToInt32(ViewState["ddlProject"]));
           ListItem lst1 = new ListItem("Select", "0");
           DropDownList list1 = (DropDownList)e.Row.Cells[6].FindControl("ddlModule");
           list1.DataTextField = "ModuleName";
           list1.DataValueField = "ModuleId";
           list1.DataSource = dt;
           list1.DataBind();
           //list1.Enabled = false;
           list1.AutoPostBack = true;
           list1.Items.Insert(0, lst1);

           //Form Values in dropdonwn
           dt = DelayworkReport.fillTask(Convert.ToInt32(ViewState["ddlModule"]));
           ListItem lst2 = new ListItem("Select", "0");
           DropDownList list2 = (DropDownList)e.Row.Cells[7].FindControl("ddlForm");
           list2.DataTextField = "EntityType";
           list2.DataValueField = "EntityId";
           list2.DataSource = dt;
           list2.DataBind();
           //list2.Enabled = false;
           list2.AutoPostBack = true;
           list2.Items.Insert(0, lst2);

           //Status in dropdown
           dt = DelayworkReport.fillStatus();
           ListItem lst3 = new ListItem("Select", "0");
           DropDownList list3 = (DropDownList)e.Row.Cells[9].FindControl("ddlStatus");
           list3.DataTextField = "CompletionValue";
           list3.DataValueField = "CompletionId";
           list3.DataSource = dt;
           list3.DataBind();
           list3.AutoPostBack = true;
           list3.Items.Insert(0, lst3);

           CheckBox cb = (CheckBox)e.Row.FindControl("CheckBox");

       }

   }
Posted
Updated 7-Dec-11 1:01am
v2
Comments
Smithers-Jones 7-Dec-11 7:01am    
Added code-block. And use a proper, descriptive subject line, not "help me". Everybody here wants help.

1 solution

OnSelectedIndexChanged event of DropDownList control, you can fill the appropriate data in the list.

ASP.NET
<aspropdownlist cssclass="TxtBox" id="Project" runat="server" tabindex="13" autopostback="true" onselectedindexchanged="Project_SelectedIndexChanged"></aspropdownlist>


Project_SelectedIndexChanged event will fill the adjacent DropDownList control.
 
Share this answer
 
Comments
Prashant Srivastava LKO 7-Dec-11 13:03pm    
I m not satisfied the id's of drodpown in Gridview itemtemplated for this I need to find control SelectedIndex changed won't help me to fill the values of dropdown but my question was how to call the id of Module in Project so this cannot be done in Selected Index changed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900