If you set a break point in the DotDotDot function does it get called? Can you paste your updated code? Can you also paste the output you're seeing and the HTML source
the code that you show me before it shows the compilation error ( which means you ask me if i run the code what happen ) I means it shows error the code that you said
No...please following code is not working as well.
SELECT *, LEFT(Description,15) + CASE WHEN LEN(Description) > 15 THEN '...' ELSE '' END AS ShortDescription
FROM MyTable
Can anybody help me out .. pls..thanks
No...please following code is not working as well.
SELECT *, LEFT(Description,15) + CASE WHEN LEN(Description) > 15 THEN '...' ELSE '' END AS ShortDescription
FROM MyTable
Can anybody help me out .. pls..thanks
Can you please show us your original code for the ListView and SqlDataSource?
Please mark as answered if this helped.
Marked as answer by kyithar on Sep 14, 2011 06:35 AM
kyithar
Member
34 Points
29 Posts
Re: sql server 2008 table
Sep 10, 2011 07:32 AM|LINK
I think I should change in sql database table's column properties to appear like that...but i am not sure..please give me idea
PNasser
Contributor
2811 Points
531 Posts
Re: sql server 2008 table
Sep 10, 2011 07:32 AM|LINK
What does this produce?
<asp:ListView ID="ListView1" runat="server" DataKeyNames="Id" OnPagePropertiesChanging="ListView1_PagePropertiesChanging"> <ItemTemplate> <li style="background-color: #DCDCDC;color: #000000;"> Name: <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' /> <br /> Description: <asp:Label ID="DescriptionLabel" runat="server" Text='<%# DotDotDot(Eval("Description")) %>' /> <br /> Price: <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' /> <br /> </li> </ItemTemplate> <LayoutTemplate> <ul ID="itemPlaceholderContainer" runat="server" style="font-family: Verdana, Arial, Helvetica, sans-serif;"> <li runat="server" id="itemPlaceholder" /> </ul> <div style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;"> <asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="5" QueryStringField="pageNumber" EnableViewState="true"> <Fields> <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" /> <asp:NumericPagerField /> <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" /> </Fields> </asp:DataPager> </div> </LayoutTemplate> </asp:ListView> the code behind is protected string DotDotDot(string dbstring) { if (dbstring.Length > 15) dbstring = dbstring.Substring(0, 15) + "..."; return dbstring; }kyithar
Member
34 Points
29 Posts
Re: sql server 2008 table
Sep 10, 2011 07:40 AM|LINK
Nothing happen in my description name its still show all character not like with dotdotdot(15...) the one 15nvarchar...
PNasser
Contributor
2811 Points
531 Posts
Re: sql server 2008 table
Sep 10, 2011 07:47 AM|LINK
If you set a break point in the DotDotDot function does it get called? Can you paste your updated code? Can you also paste the output you're seeing and the HTML source
kyithar
Member
34 Points
29 Posts
Re: sql server 2008 table
Sep 10, 2011 08:02 AM|LINK
the code that you show me before it shows the compilation error ( which means you ask me if i run the code what happen ) I means it shows error the code that you said
kyithar
Member
34 Points
29 Posts
Re: sql server 2008 table
Sep 10, 2011 12:30 PM|LINK
Hi...
Can anybody help me out for this...please
chohmann
Star
9385 Points
1644 Posts
Re: sql server 2008 table
Sep 11, 2011 06:36 AM|LINK
Change the Select statement for your datasource to something like this:
Then you can reference ShortDescription in your ListView.
kyithar
Member
34 Points
29 Posts
Re: sql server 2008 table
Sep 12, 2011 09:17 AM|LINK
No...please following code is not working as well.
chohmann
Star
9385 Points
1644 Posts
Re: sql server 2008 table
Sep 12, 2011 09:33 PM|LINK
Can you please show us your original code for the ListView and SqlDataSource?
KumarHarsh
All-Star
15133 Points
3647 Posts
Re: sql server 2008 table
Sep 13, 2011 05:36 AM|LINK
try this,
SELECT *, CASE WHEN LEN(Description) > 15 THEN CONVERT(varchar(15), description)+ '...' ELSE description END AS ShortDescription
FROM MyTable
Kumar Harsh