I have a repeater that is supposed to create div tags with their onclick functions from databind. Which is like
onclick='<%# "functionname('" + Eval("somestring") +"');" %>'
but the single quotes ' after the js func ( and before ) , they become something like ?,= ..
I don't understand what's happening. .. the full code is below
<div id="dvPager">
<asp:Repeater ID="pagerSorular" runat="server">
<ItemTemplate>
<div class='<%# "pageritem pagertext" + ((this.PageNumber == int.Parse(Container.DataItem.ToString())) ? " pagerselected" : "") %>'
onclick='<%# "gotopage('" + this.PageName + "', " + Container.DataItem + ");" %>'>
<%# Container.DataItem %>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
and codebehind is:
public int PageNumber
{
get
{
string strPgNum = Request.QueryString["pg"] as String;
if (!String.IsNullOrEmpty(strPgNum))
{
int pgnum;
if (int.TryParse(strPgNum, out pgnum))
{
if (pgnum <= 0)
{
return pgnum;
}
else
{
return 1;
}
}
else
{
return 1;
}
}
else
{
return 1;
}
}
}
public string PageName {
get
{
string url = Request.Url.ToString();
string[] parts = url.Split(new char[]{'/'});
return parts[parts.Length - 1];
}
}
public void Doldur(List<SoruGridView> sorulistesi)
{
gridSorular.DataSource = sorulistesi;
gridSorular.DataBind();
///
PagerYap(sorulistesi);
}
protected void PagerYap(List<SoruGridView> sorulistesi)
{
List<int> numpgs = new List<int>(); int count = 1;
foreach (SoruGridView sgv in sorulistesi)
{
numpgs.Add(count);
count++;
}
pagerSorular.DataSource = numpgs.ToArray();
pagerSorular.DataBind();
}