Why does DropDownList.SelectedValue is relied on viewstate?

后端 未结 4 485
南方客
南方客 2021-02-08 22:01

If I set on my page : EnableViewState=\"true\" ViewStateMode=\"Disabled\" - Then - the Viewstate is disable for the page ( unless override...)

The

4条回答
  •  北荒
    北荒 (楼主)
    2021-02-08 22:36

          protected void Page_Load(object sender, EventArgs e)
                {
                    (!Page.IsPostBack)
                    {
                        string qry = "SELECT TOP(5)xxx, xxxx FROM dbo.xxxxxx ";
                        DataSet ds = new DataSet();
                        ds = SqlHelper.ExecInDS(qry);
                        drpDwn.DataSource = ds.Tables[0];
                        drpDwn.DataValueField = Convert.ToString(ds.Tables[0].Columns["xxx"]);
                        drpDwn.DataTextField = Convert.ToString(ds.Tables[0].Columns["xxx"]);                   
                        drpDwn.DataBind();
                    }
                   //Here You will get selected value from dropdown
                   string sss= Request.Form["drpDwn"];
        }
    

提交回复
热议问题