0

这是页面加载功能代码

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //DropDownList Binding through bussiness logic
            Bussiness_logic.DropDownList_Bind(DDL_U, "SHORT_DESC", "UNIT_CODE", "UNIT_SOURCE");
            Bussiness_logic.DropDownList_Bind(DDL_Branch, "TYPE_DESC", "TYPE_CODE", "BRANCH_SOURCE");
        }
        if (Request.QueryString["File"] != null)
            {

                string fileNo = Request.QueryString["File"].ToString();
                Bussiness_logic.OpenConnection();
                SqlCommand com = new SqlCommand("LINK_DATA", Bussiness_logic.con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@FILE", fileNo);
                SqlDataReader dtr = com.ExecuteReader();
                if (dtr.HasRows)
                {
                    dtr.Read();
                    {
                        TxtFile.Text = dtr["FILE_NO"].ToString();
                        DDL_Branch.SelectedItem.Value = dtr["TYPE_DESC"].ToString();
                        TxtSub.Text = dtr["SUBJECT"].ToString();
                        DDL_U.SelectedItem.Value = dtr["SHORT_DESC"].ToString();
                    }
                }

                Bussiness_logic.CloseConnection();
                Label1.Text = "";
            }
      }


我的问题是它没有更新数据,它只采用在页面加载功能时填充的值

4

1 回答 1

1

可能您没有使用Page.IsPostbackProperty。在页面生命周期中,Page_Load将在您的按钮的Click事件处理程序之前执行。尝试包装从 SQL 获取值的代码,如下所示:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        // get values from SQL
    }
}
于 2013-07-16T08:39:53.797 回答