En iyi yanıtlayıcılar
Bu Kodun Neresinde Hata Var ???

Soru
-
<asp:repeater ID=NewsRepeater runat="server">
<ItemTemplate>
<div id="content-bottom">
<div class="content-bottom-inner">
<ul>
<li>
<h4>
<%#DataBinder.Eval(Container.DataItem,"NewsTitle") %></h4>
</li>
<li>
<%#DataBinder.Eval(Container.DataItem,"NewsImg") %>
</li>
<li>
<%#DataBinder.Eval(Container.DataItem,"NewsText") %>
</li>
<li>
<%#DataBinder.Eval(Container.DataItem,"NewsLink") %>
</li>
</ul>
</div>
</div>
</ItemTemplate>
</asp:repeater>
<script type="text/javascript">
$(window).scroll(function () {
if ($(window).scrollTop() == $(document).height() - $(window).height())
{
$.ajax({
type: "POST",
url: "Default3.aspx/ItemsGet",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: AjaxSucceeded,
error: AjaxFailed
});
function AjaxSucceeded() {
alert("result.d");
}
function AjaxFailed() {
alert("Failed");
}
}
});</script>public int CurrentPage
{
get
{
// look for current page in ViewState
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 0; // default to showing the first page
else
return (int)o;
}
set
{
this.ViewState["_CurrentPage"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
ItemsGet();
}
[WebMethod]
public void ItemsGet()
{
SqlConnection myConnection = new SqlConnection("Data Source=localhost\\sqlexpress;Initial Catalog=db1;Integrated Security=True");
SqlDataAdapter myCommand = new SqlDataAdapter("SELECT [NewsTitle],[NewsImg] ,[NewsText],[NewsLink] FROM NewsTable ORDER BY id desc", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds);
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 3;
objPds.CurrentPageIndex = CurrentPage;
NewsRepeater.DataSource = objPds;
NewsRepeater.DataBind();
}
Yanıtlar
-
Bu şekilde JQUERY ile NewsRepeater sunucu nesnesini bind edemezsiniz. ItemsGet fonksiyonu geriye bir liste döndürmeli ve o listeyi client tarafında sizin bind etmeniz gerekmektedir.
http://weblogs.asp.net/ahmedmoosa/archive/2010/10/30/bind-gridview-using-jquery.aspx
Veya ajaxtoolkit kurarak UpdatePanel kullanarak bu işlemi yapabilirsiniz. Aşağıdaki adreste örnek mevcut.
http://msdn.microsoft.com/en-us/library/bb386452.aspx
Ahmet Kaymaz
http://www.ahmetkaymaz.com
C# VB.NET ASP.NET kitabı- Yanıt Olarak İşaretleyen Ali Rıza İnceoğlu 8 Nisan 2013 Pazartesi 14:15
-
Computer Engineer & Software Developer www.ulusoyy.com - www.huseyinulusoy.com
- Yanıt Olarak İşaretleyen Ali Rıza İnceoğlu 8 Nisan 2013 Pazartesi 14:15
Tüm Yanıtlar
-
Bu şekilde JQUERY ile NewsRepeater sunucu nesnesini bind edemezsiniz. ItemsGet fonksiyonu geriye bir liste döndürmeli ve o listeyi client tarafında sizin bind etmeniz gerekmektedir.
http://weblogs.asp.net/ahmedmoosa/archive/2010/10/30/bind-gridview-using-jquery.aspx
Veya ajaxtoolkit kurarak UpdatePanel kullanarak bu işlemi yapabilirsiniz. Aşağıdaki adreste örnek mevcut.
http://msdn.microsoft.com/en-us/library/bb386452.aspx
Ahmet Kaymaz
http://www.ahmetkaymaz.com
C# VB.NET ASP.NET kitabı- Yanıt Olarak İşaretleyen Ali Rıza İnceoğlu 8 Nisan 2013 Pazartesi 14:15
-
-
-
Computer Engineer & Software Developer www.ulusoyy.com - www.huseyinulusoy.com
- Yanıt Olarak İşaretleyen Ali Rıza İnceoğlu 8 Nisan 2013 Pazartesi 14:15