Exemple #1
0
    protected void LoadDropDownList()
    {
        DataTable tbl = dc.GetAuthors();

        AuthorList.DataSource     = tbl;
        AuthorList.DataTextField  = "AuthorName";
        AuthorList.DataValueField = "AuthorKey";
        AuthorList.DataBind();
        AuthorList.Items.Insert(0, "Choose an Author");
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            lbl_userid.Text = Session["user_id"].ToString();

            SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);

            SqlCommand cmd = new SqlCommand();
            cmd.Connection  = cn;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from Authors";

            cn.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            AuthorList.DataSource     = dr;
            AuthorList.DataTextField  = "Name";
            AuthorList.DataValueField = "Name";
            AuthorList.DataBind();


            cn.Close();
        }
    }
Exemple #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                if (Session["user_id"] == null)
                {
                    Response.Redirect("Login.aspx");
                }
                lbl_userid.Text = Session["user_id"].ToString();
            }
            catch (NullReferenceException e1)
            {
                Response.Write("<script>alert('Please Login!')</script>");
            }


            SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);

            SqlCommand cmd = new SqlCommand();
            cmd.Connection  = cn;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from Authors";

            cn.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            AuthorList.DataSource     = dr;
            AuthorList.DataTextField  = "Name";
            AuthorList.DataValueField = "Name";
            AuthorList.DataBind();


            cn.Close();
        }
    }