السلام عليكم ..
عندي مشكلة حصلت لي عندما حولت صفحة الى usercontrols .. المشكلة هي ان أمر update أصبح لا يعمل .. وهذه المشكلة حصلت عندما لغيت ispostback! في pageload .. ولقد اضطررت أن ألغي الأمر هذا لأن في الصفحة في دالة index_changed مرتبطة ب dropdownlist عندما أغير ال index لل dropdownlist تختفي محتوياتها .. وما حلت المشكلة الا بإزالة if (!ispostback)
وهذا كود pageload
// if(this.IsPostBack)
DataSet ds=new DataSet();
Display disp=new DAL.Display();
ds=disp.DisplayQuestions();
DataTable dt = ds.Tables[0];
dt.Rows.Add(new Object[]{0,"Select a Question to edit"});
DataView dv = new DataView(dt);
DropDownList1.DataSource =dv;
DropDownList1.DataTextField = "Questions";
DropDownList1.DataValueField = "FAQID";
DropDownList1.DataBind();
DropDownList1.SelectedIndex = dt.Rows.Count -1;
}وهذا كود index_changed
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
string x = DropDownList1.SelectedValue;
DataSet ds=new DataSet();
DAL.Display disp=new DAL.Display();
ds=disp.DisplayGeneralFaqs(x);
DataTable dt = ds.Tables[0];
DataView dv = new DataView(dt);
if(dt.Rows.Count!=0)
{
DropDownList2.SelectedValue = (string)Convert.ChangeType(dt.Rows[0][1], typeof(string));
QuestionTB.Text = (string)dt.Rows[0][2];
AnswerTB.Text = (string)dt.Rows[0][3];
LastEditLabel.Text = (string)Convert.ChangeType(dt.Rows[0][4], typeof(string));
publist.SelectedIndex = (int)Convert.ChangeType(dt.Rows[0][5], typeof(int));
}
}أفيدونا باقتراجاتكم ..
وجزاكم ربي عني كل خير ..