asiehmohammadian
پنج شنبه 09 بهمن 1393, 11:12 صبح
سلام به همه
من یک ریپیتر دارم که در اتصالش به بانک مشکل دارم
کد html اینه :
<div id="dvAccordian" style = "width:400px"> <asp:Repeater ID="rptAccordian" runat="server"> <ItemTemplate> <h3> <%# Eval("title") %></h3> <div> <p> <%# Eval("content") %> </p> </div> </ItemTemplate> </asp:Repeater></div>
ودر قسمت کد بیهاند این ونوشتم :
protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(Request.QueryString["id"]))
{
this.BindRepeater(Convert.ToInt32(Request.QueryStr ing["id"]));
}
}
private void BindRepeater(int id)
{
SqlConnection con=new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\Database.mdf;Integrated Security=True;User Instance=True");
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select title, content from tblcontent where fkid=@id";
cmd.Parameters.AddWithValue("@id", SqlDbType.Int);
cmd.Parameters["@id"].Value = id;
cmd.Connection = con;
con.Open();
rptAccordian.DataSource = cmd.ExecuteReader();
rptAccordian.DataBind();
con.Close();
}
}
نمیدونم مشکل کد کجاست که هیچی نمایش نمیده
اون fkid کلید خارجی در یک جدول دیگه است
دوستان خواهش میکنم لطف کنید راهنماییم کنید
من یک ریپیتر دارم که در اتصالش به بانک مشکل دارم
کد html اینه :
<div id="dvAccordian" style = "width:400px"> <asp:Repeater ID="rptAccordian" runat="server"> <ItemTemplate> <h3> <%# Eval("title") %></h3> <div> <p> <%# Eval("content") %> </p> </div> </ItemTemplate> </asp:Repeater></div>
ودر قسمت کد بیهاند این ونوشتم :
protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(Request.QueryString["id"]))
{
this.BindRepeater(Convert.ToInt32(Request.QueryStr ing["id"]));
}
}
private void BindRepeater(int id)
{
SqlConnection con=new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\Database.mdf;Integrated Security=True;User Instance=True");
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select title, content from tblcontent where fkid=@id";
cmd.Parameters.AddWithValue("@id", SqlDbType.Int);
cmd.Parameters["@id"].Value = id;
cmd.Connection = con;
con.Open();
rptAccordian.DataSource = cmd.ExecuteReader();
rptAccordian.DataBind();
con.Close();
}
}
نمیدونم مشکل کد کجاست که هیچی نمایش نمیده
اون fkid کلید خارجی در یک جدول دیگه است
دوستان خواهش میکنم لطف کنید راهنماییم کنید