面对dropdown.SelectedItem中的问题 [英] Facing Problem in dropdown.SelectedItem

查看:92
本文介绍了面对dropdown.SelectedItem中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我正在将我的特定学生的学费类型绑定到下拉列表(ddlFeeType)。对此它工作正常但是从下拉列表中选择特定费用时,下面没有选择特定费用是我的代码对于整页。这是必要的



这里的页面将打开搜索text_box1。在输入名称(或)reg_id之后,它将在grid_view1中显示根据grid_view1中显示的学生的reg_id后的名称(或)reg_id来显示记录。根据reg_id我会将fee_types绑定到下拉(ddlfeetype)。我向下给出了reg_id链接按钮代码并将费用类型绑定到ddlfeetypes。



//链接按钮代码

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);
            PickFeesofParticularID();
        }





//这是将fee_types绑定到下拉列表的功能



//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.DataBind();
                ddlFeeTypes.Items.Insert(0, "--Select--");
                panelSearch.Visible = false;
                PanelFeeTypes.Visible = true;
                lblSelectMonth.Visible = false;
                ddlMonth.Visible = false;
                gridviewCandidateDetails.Visible = false;
                panelAllFeeDetails.Visible = false;
            }
        }



//这是ddlFeeTypes_SelectedIndexChanged的代码


//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";
                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..

推荐答案

在将数据绑定到下拉列表时,我们必须注意数据值字段和数据文本字段...上面我正在取数据值字段位和数据文本字段字符串,因为它没有选择特定项目...稍后我改变那一个,我得到积极的结果...结论位在绑定时产生问题..
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..


这篇关于面对dropdown.SelectedItem中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆