Wednesday, 23 October 2019

Bind list in DropDown in asp



Bind list in DropDown in asp


public void BindLoaction2(DropDownList Drop)
    {
        cmd = new SqlCommand("select Location_Name,LID from dbo.Location_Master", con);
       
        try
        {
            con.Open();
            Drop.AppendDataBoundItems = true;
            Drop.DataSource = cmd.ExecuteReader();
            Drop.DataTextField = "Location_Name";
            Drop.DataValueField = "LID";
            Drop.DataBind();
        }
        catch (SqlException)
        {

        }
        finally
        {
            con.Close();
        }
    }

No comments:

Post a Comment