Click here to Skip to main content
15,893,401 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
C#
protected void lblStudent_ID_Click(object sender, EventArgs e)
        {
            LinkButton lbtn = (LinkButton)sender;
            Session["lbtnStudent_id"] = Convert.ToString(lbtn.Text);
            PickFeesofParticularID();
        }


//this is the function for binding the fee_types to drop down list
C#
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.DataBind();
                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
C#
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";
                ddlMonth.DataBind();
                panelSearch.Visible = false;
                PanelFeeTypes.Visible = true;
                gridviewCandidateDetails.Visible = false;
                ddlMonth.Visible = true;
                lblSelectMonth.Visible = true;
                panelAllFeeDetails.Visible = false;
            }
            else
            {

            }
        }

//here i am unable to display full code and may be i am unable to ask properly it is my fault..
Posted
Updated 5-Mar-13 0:48am
v2
Comments
willington.d 5-Mar-13 7:00am    
Have you set AutoPostback property is true in ddlFeeTypes?
ntitish 5-Mar-13 7:05am    
yes sir....i had a dought that it will depend on the panel on which we are taking...
willington.d 5-Mar-13 7:16am    
Coud you please post your HTML code for this dropdown?
ntitish 5-Mar-13 7:22am    
sure sir..
//this was my code
<asp:DropDownList ID="ddlFeeTypes" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlFeeTypes_SelectedIndexChanged">
ntitish 5-Mar-13 7:40am    
sir did u got my problem......

1 solution

while binding the data to the drop down we have to take care data value field and data text field...above i am taking data value field bit and data text field string due to that it is not selecting particular item ...later i changed that one and i am getting positive out put...conclusion bit makes problem while binding..
 
Share this answer
 

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