void fillAuthorPublisherValues()
    {
        try
        {
            SqlConnection conn = new SqlConnection(strConn);
            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }

            SqlCommand     sqlCmd      = new SqlCommand(@"SELECT author_name FROM author_master_table;", conn);
            SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlCmd);
            DataTable      dt          = new DataTable();
            dataAdapter.Fill(dt);
            AuthorNameDropDownList.DataSource     = dt;
            AuthorNameDropDownList.DataValueField = "author_name";
            AuthorNameDropDownList.DataBind();

            sqlCmd      = new SqlCommand("SELECT publisher_name FROM publisher_master_table;", conn);
            dataAdapter = new SqlDataAdapter(sqlCmd);
            dt          = new DataTable();
            dataAdapter.Fill(dt);
            PublisherNameDropDownList.DataSource     = dt;
            PublisherNameDropDownList.DataValueField = "publisher_name";
            PublisherNameDropDownList.DataBind();
        }
        catch (Exception ex)
        {
        }
    }
Beispiel #2
0
        void fillAuthorPublisherValues()
        {
            try
            {
                SqlConnection con = new SqlConnection(strcon);
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                SqlCommand     cmd = new SqlCommand("SELECT author_name FROM author_master_tb1;", con);
                SqlDataAdapter da  = new SqlDataAdapter(cmd);
                DataTable      dt  = new DataTable();
                da.Fill(dt);
                AuthorNameDropDownList.DataSource     = dt;
                AuthorNameDropDownList.DataValueField = "author_name";
                AuthorNameDropDownList.DataBind();

                cmd = new SqlCommand("SELECT publisher_name FROM publisher_master_tb1;", con);
                da  = new SqlDataAdapter(cmd);
                dt  = new DataTable();
                da.Fill(dt);
                PublisherDropDownList.DataSource     = dt;
                PublisherDropDownList.DataValueField = "publisher_name";
                PublisherDropDownList.DataBind();

                //con.Close();
            }
            catch (Exception ex)
            {
                Response.Write("<script language='javascript'>alert('" + ex.Message + "');</script");
            }
        }