Wednesday, 25 January 2017

Data Blind on Dropdown List 

Data Blind on Dropdown List 

                                                              C# Code


 protected void DDLEvalStatusBind()
        {
          
            DataTable dt = new DataTable();
            using (MySqlConnection con = new MySqlConnection(conStr))
            {
                con.Open();
                string str = "select kdm.Keyword_Value,kdm.Keyword_Text from keyword_details_mst                       str += "   kdm inner join keyword_mst km on km.Keyword_name = kdm.Keyword_name";
                str += " where km.Keyword_name = 'Status' order by kdm.Keyword_Text asc";

                MySqlCommand cmd = new MySqlCommand(str, con);
                MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                da.Fill(dt);
                con.Close();
                ddlEvalStatus.DataSource = dt;
                ddlEvalStatus.DataTextField = "Keyword_Text";
                ddlEvalStatus.DataValueField = "Keyword_Value";
                ddlEvalStatus.DataBind();
                ddlEvalStatus.Items.Insert(0, new ListItem("--Select Designation--", ""));
            }
        }



 protected void ddlEvalStatus_SelectedIndexChanged(object sender, EventArgs e)
        {

            fnReadEvaluation("");

        }


Code  add with query:

 if (ddlEvalStatus.SelectedIndex > 0)
            {
                sqlStr += " AND JUM .JD_EvalStatus='" + ddlEvalStatus.SelectedValue + "'";
            }



ASP.Net Code

 <asp:DropDownList ID="ddlEvalStatus" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlEvalStatus_SelectedIndexChanged" CssClass="dropdownsmall-style"></asp:DropDownList>



No comments:

Post a Comment