Click here to Skip to main content
14,430,070 members

Facing Problem in dropdown.SelectedItem

ntitish asked:

Open original thread
Actually i am binding my types of fees of a particular student to dropdown list(ddlFeeType).up to this it is working fine but while selecting the particular fee from dropdown list it is not selecting the particular fee here below is my code for full page.which is necessary for this

here the page will open with search text_box1. after entering the name(or)reg_id it will display the record according to the name(or)reg_id in a grid_view1 after clicking on the reg_id of a student which is displayed on the grid_view1.according to that reg_id i will bind the fee_types to the drop down(ddlfeetype).here down i am giving reg_id link button code and binding the fee types to ddlfeetypes.

//link button code
protected void lblStudent_ID_Click(object sender, EventArgs e)
            LinkButton lbtn = (LinkButton)sender;
            Session["lbtnStudent_id"] = Convert.ToString(lbtn.Text);

//this is the function for binding the fee_types to drop down list
public void PickFeesofParticularID()
            SqlCommand cmdPickFeeses = DBManager.DataAccess.command();
            cmdPickFeeses.Parameters.Add(new SqlParameter("@option", SqlDbType.VarChar, 50));
            cmdPickFeeses.Parameters["@option"].Value = "PickFeesesOfParticularID";

            cmdPickFeeses.Parameters.Add(new SqlParameter("@Student_ID", SqlDbType.VarChar, 50));
            cmdPickFeeses.Parameters["@Student_ID"].Value = Session["lbtnStudent_id"].ToString();                      

            string sqlquery = "SchoolProc";
            DataSet dsPickFees = DBManager.DataAccess.getdata(sqlquery);
            if (dsPickFees.Tables[0].Rows.Count > 0)
                ddlFeeTypes.DataSource = dsPickFees.Tables[0];
                ddlFeeTypes.DataTextField = "Fee_Type";
                ddlFeeTypes.DataValueField = "Annual_Month";
                ddlFeeTypes.Items.Insert(0, "--Select--");
                panelSearch.Visible = false;
                PanelFeeTypes.Visible = true;
                lblSelectMonth.Visible = false;
                ddlMonth.Visible = false;
                gridviewCandidateDetails.Visible = false;
                panelAllFeeDetails.Visible = false;

//this the code for ddlFeeTypes_SelectedIndexChanged
protected void ddlFeeTypes_SelectedIndexChanged(object sender, EventArgs e)
            string Fee_type = ddlFeeTypes.SelectedIndex.ToString();
            ViewState["Fee_type"] = Fee_type;
            //ddlFeeTypes.Text = ViewState["Fee_type"].ToString();
            SqlCommand cmdPickMonthYear = DBManager.DataAccess.command();
            cmdPickMonthYear.Parameters.Add(new SqlParameter("@option", SqlDbType.VarChar, 50));
            cmdPickMonthYear.Parameters["@option"].Value = "PickMonthYear";

            cmdPickMonthYear.Parameters.Add(new SqlParameter("@Annual_Month", SqlDbType.Bit));
            cmdPickMonthYear.Parameters["@Annual_Month"].Value = ddlFeeTypes.SelectedValue;

            string sqlquery = "SchoolProc";
            DataSet dsPickMonthYear = DBManager.DataAccess.getdata(sqlquery);
            if (dsPickMonthYear.Tables[0].Rows.Count > 0)
                ddlMonth.DataSource = dsPickMonthYear.Tables[0];
                ddlMonth.DataTextField = "Annual_month";
                ddlMonth.DataValueField = "Annual_month";
                panelSearch.Visible = false;
                PanelFeeTypes.Visible = true;
                gridviewCandidateDetails.Visible = false;
                ddlMonth.Visible = true;
                lblSelectMonth.Visible = true;
                panelAllFeeDetails.Visible = false;


//here i am unable to display full code and may be i am unable to ask properly it is my fault..


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100