Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to ask advise for how to populate drop down list for CTR No based on user selection of Project No. Example: If user select Project A, then populate drop down in CTR No for Project A. I have search other forum about populate drop down menu but I can't find solution that fit with my problem.

Appreciate for advise. Thank You.

What I have tried:

I have populate the drop down menu in GridView.

<asp:DropDownList ID="dd_project_no" runat="server" AutoPostBack="true" CssClass="tb_table1_kecik">
<asp:DropDownList ID="dd_pro_ov" runat="server" CssClass="tb_table1_kecik">

Code behind:

protected void GridView1_onRowDataBound(object sender, GridViewRowEventArgs e)
if (task_title.Text.Contains("Originator"))
//if edit mode
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
DropDownList dd_project_no = (DropDownList)e.Row.FindControl("dd_project_no");

using (SPSite site = new SPSite(SPContext.Current.Web.Url))
using (SPWeb web = site.OpenWeb())

SPList list = web.Lists["Timesheet Member"];
SPQuery query = new SPQuery();
query.Query = @"<Where><Eq><FieldRef Name='Name'/><Value Type='Text'>" + tb_empname.Text + "</Value></Eq></Where>";

DataTable caml = list.GetItems(query).GetDataTable();
DataView view = new DataView(caml);
DataTable tbl = view.ToTable(true, "Title");
dd_project_no.DataSource = tbl;
dd_project_no.DataTextField = "Title";
dd_project_no.DataValueField = "Title";
dd_project_no.SelectedIndex = 1;
dd_project_no.Items.Insert(0, new ListItem("Select", "0"));

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