After selecting the ddlprogram it should display the ddl_Location where the programs are avaliable
aspx file
aspx.cs
protected void gvProgram_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataSet ds = new DataSet();
Btech.Mode = "BindData";
ds = objDal.Adm(Btech);
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (ds.Tables[0].Rows.Count > 0 && ds.Tables[1].Rows.Count > 0)
{
DropDownList ddlProgram = (DropDownList)e.Row.FindControl("ddlProgram");
ddlProgram.Items.Clear();
ddlProgram.DataSource = ds.Tables[13];
ddlProgram.DataTextField = "Description";
ddlProgram.DataValueField = "CourseID";
ddlProgram.DataBind();
ddlProgram.Items.Insert(0, new ListItem("Select course", "0"));
DropDownList ddl_Location = (DropDownList)e.Row.FindControl("ddl_Location");
//ddlTeacherNames.Items.Clear();
ddl_Location.DataSource = ds.Tables[14];
ddl_Location.DataTextField = "CenterName";
ddl_Location.DataValueField = "CentreCode";
ddl_Location.DataBind();
ddl_Location.Items.Insert(0, new ListItem("Select Location", "0"));
}
}
}
protected void ddlProgram_SelectedIndexChanged(object sender, EventArgs e)
{
}
Naimish MakwanaPosted Jan 18, 2024, 11:33 AM
It seems like you want to populate the
ddl_Locationdropdown based on the selected value of theddlProgramdropdown. You can achieve this by fetching the relevant data inside theddlProgram_SelectedIndexChangedevent. Here is a sample code snippet:In this code,
FetchLocationsForProgram(selectedProgram)is a placeholder method which you should replace with your actual logic to fetch the locations based on the selected program. This method should return aDataSetorDataTablewhich can be bound toddl_Location.Please replace the placeholder method with your actual data fetching logic.
Thanks.