Doesn't oned_gk's method work? You don't need any event if you want to open the full article on new page. NavigateURL will do the redirect with querystring. Or you want to show it on the same page?
Marked as answer by Mac14 on Dec 16, 2012 02:17 PM
Good news! I solved the problem. It was about my sqlconnection which doesn't retrieve Id. Now it all works But the problem is detail.aspx comes empty. (even though I have sql connection adn gridview). How can I fix it? Btw is it possible to open the article
on the same page by just changing the url? I don't know which one is easier. You can send me the easier one. THANK YOU SO MUCH!!!!!!!!
Hey buddy. Thanks for your caring and your code. I tried to use it but repater comes empty. I don't know why. I will try to change the codes for gridview and keep you updated. Thanks!
Now In detail.aspx page, what should I do? I have gridview and an sqldatasource which is connected to the same DB.Because after the codes the detail.aspx page comes empty :(
gregaDro
Member
318 Points
65 Posts
Re: Limiting data lenght
Dec 16, 2012 12:09 PM|LINK
1.
<%# ((Eval("article").ToString()).Lenght > 200) ? Eval("article").ToString().Substring(0, 200) : Eval("article").ToString() %>2.
Doesn't oned_gk's method work? You don't need any event if you want to open the full article on new page. NavigateURL will do the redirect with querystring. Or you want to show it on the same page?
oned_gk
All-Star
31531 Points
6441 Posts
Re: Limiting data lenght
Dec 16, 2012 12:22 PM|LINK
try
<asp:HyperLink ID="HyperLink1" runat="server" visible='<%# Eval("article").Length > 200 %>' NavigateUrl='<%# Eval("id","Detail.aspx?id={0}") %>'>Read more ..</asp:HyperLink>or
<asp:HyperLink ID="HyperLink2" runat="server" visible='<%# Eval("article").Length > 200 ? True : False %>' NavigateUrl='<%# Eval("id","Detail.aspx?id={0}") %>'>Read more ..</asp:HyperLink>RameshRajend...
Star
7983 Points
2099 Posts
Re: Limiting data lenght
Dec 16, 2012 12:56 PM|LINK
hellow try my code ya...I have check if condition for my methode.Please look that...... I am waiting for your reply.......
Mac14
Member
46 Points
71 Posts
Re: Limiting data lenght
Dec 16, 2012 01:19 PM|LINK
Good news! I solved the problem. It was about my sqlconnection which doesn't retrieve Id. Now it all works But the problem is detail.aspx comes empty. (even though I have sql connection adn gridview). How can I fix it? Btw is it possible to open the article on the same page by just changing the url? I don't know which one is easier. You can send me the easier one. THANK YOU SO MUCH!!!!!!!!
btw RameshRajendran,
Hey buddy. Thanks for your caring and your code. I tried to use it but repater comes empty. I don't know why. I will try to change the codes for gridview and keep you updated. Thanks!
have a great day!
RameshRajend...
Star
7983 Points
2099 Posts
Re: Limiting data lenght
Dec 16, 2012 01:32 PM|LINK
Hey try in gridview
<asp:TemplateField> <ItemTemplate> <asp:Label ID="articlelabel" runat="server" Text='<%# GetArticle((string)Eval("article"))%>'></asp:Label> <br /> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("id","Detail.aspx?id={0}") %>'>Read more ..</asp:HyperLink> </ItemTemplate> </asp:TemplateField> //CodeBehind side public string GetArticle(string article) { if (article.Length > 200) { article= string.Format("{0}...",article.Substring(0, 200)); } returnarticle; }Mac14
Member
46 Points
71 Posts
Re: Limiting data lenght
Dec 16, 2012 01:59 PM|LINK
Thanks for your code man :)
This code also solves the expectpiton problem :))
Now In detail.aspx page, what should I do? I have gridview and an sqldatasource which is connected to the same DB.Because after the codes the detail.aspx page comes empty :(
oned_gk
All-Star
31531 Points
6441 Posts
Re: Limiting data lenght
Dec 16, 2012 02:09 PM|LINK
RameshRajend...
Star
7983 Points
2099 Posts
Re: Limiting data lenght
Dec 16, 2012 02:10 PM|LINK
I think article length was below 200.you check that.and change if conditions for greater than small values and bind that valus then ...
for
if (article.Length > 30) { article= string.Format("{0}...", article.Substring(0, 30)); }Mac14
Member
46 Points
71 Posts
Re: Limiting data lenght
Dec 16, 2012 02:17 PM|LINK
okay. Thanks Everybody for your all help! You don't know how much you helped me! :)
Thanks you so so much!
:)
Have a great day!