PDA

View Full Version : سوال: فراخوانی مقدار پیش فرض textbox از datalist صفحه قبل



maralahmady
دوشنبه 30 فروردین 1395, 12:36 عصر
سلام برای فراخوانی مقدار پیش فرض textbox های نمایش جزییات یک فایل انتخاب شده از دیتالیست صفحه قبل کد را به این صورت نوشتم




public string title,chbody,keyword,comment,free,english,id_file, id_field,translate,price,state,address_f;

protected void Page_Load(object sender, EventArgs e)
{
SqlConnection cnc = new SqlConnection(ConfigurationManager.ConnectionStrin gs["db_piliConnectionString1"].ToString());
cnc.Open();
SqlCommand cmd = new SqlCommand("SELECT id_file,title,chbody,keyword,comment,id_field,free ,english,translate,price,state,address_f FROM t_file", cnc);

DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader());
cnc.Close();
//*************************
title = dt.Rows[0]["title"].ToString();
chbody = dt.Rows[0]["chbody"].ToString();
keyword = dt.Rows[0]["keyword"].ToString();
comment = dt.Rows[0]["comment"].ToString();
free = dt.Rows[0]["free"].ToString();
english = dt.Rows[0]["english"].ToString();
state = dt.Rows[0]["state"].ToString();
translate = dt.Rows[0]["translate"].ToString();
id_field = dt.Rows[0]["id_field"].ToString();
price = dt.Rows[0]["price"].ToString();
address_f = dt.Rows[0]["address_f"].ToString();


//**********
TextBox3.Text = title;
TextBox4.Text = chbody;
TextBox5.Text = keyword;
TextBox6.Text = comment;
CheckBox1.Checked = System.Convert.ToBoolean(english);
CheckBox2.Checked = System.Convert.ToBoolean(free);
CheckBox3.Checked = System.Convert.ToBoolean(translate);
CheckBox4.Checked = System.Convert.ToBoolean(state);
DropDownList1.Text=id_field;
TextBox7.Text = price;
Label2.Text = address_f;
}

ولی جزییات فایلی که از دیتالست صفحه قبل انتخاب شده را نمایش نمیدهد و اولین فایل موجود در دیتالیست را نمایش میدهد
به عبارتی در اختصاص دادن id فایل انتخاب شده از دیتالیست به این صفحه مشکل دارد
چه تغییری در کد انجام دهم؟
این خط کد رو درون کدها قرار میدم خطا میده where id_file= + Request.QueryString["id"].ToString()