Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Text in Datagrid is truncated for unknown reason

Author  Topic 

tmcgree
Starting Member

4 Posts

Posted - 2008-11-20 : 11:41:03
I support a web app that uses a Datagrid to display answers to questions answered by the users. For some reason the answers that are text (stored in the SQL database as varchar(8000)) are truncated at 256 characters. The peculiar thing is that when these same answers are displayed on another page in a free form text box the string is not truncated and displays properly. Is there any reason that the stored procedure reponsible for populating my datagrid is truncating this string at 256 characters?

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-11-20 : 11:51:06
maybe you have parameters defined as 256 length?

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.1 out!
Go to Top of Page

tmcgree
Starting Member

4 Posts

Posted - 2008-11-20 : 12:11:23
No I have looked into that...no parameters are set...unless there is some kind of built in restriction that I am unaware of...
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-11-20 : 12:15:07
restriction in what?

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.1 out!
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-11-20 : 12:31:58
post your script here. I have had similar problems, but later realized, i set a data length somewhere in my script
Go to Top of Page

tmcgree
Starting Member

4 Posts

Posted - 2008-11-20 : 13:10:54
Here is the html script for my datagrid - the column giving me the problem is the "response" column:

<asp:datagrid id="dgParent" CssClass="gridview" runat="server" AutoGenerateColumns="False" PageSize="25" AllowSorting="True" AllowPaging="True">
<HeaderStyle CssClass="headerstyle"></HeaderStyle>
<ItemStyle CssClass="rowstyle"></ItemStyle>
<AlternatingItemStyle CssClass="alternatingrowstyle"></AlternatingItemStyle>
<Columns>
<asp:TemplateColumn SortExpression="category">
<HeaderTemplate>
<asp:LinkButton ID="lnkCategory" Runat="server" CommandName="sort" CommandArgument="category">Category</asp:LinkButton>
<asp:Image ID="imgCategory" Runat="server" Visible="False" /><br />
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblCategory" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"category") %>' />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="question">
<HeaderTemplate>
<asp:LinkButton ID="lnkQuestion" Runat="server" CommandName="sort" CommandArgument="question">Question</asp:LinkButton>
<asp:Image ID="imgQuestion" Runat="server" Visible="False" /><br />
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblQuestion" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"question") %>' />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="response">
<HeaderTemplate>
<asp:LinkButton ID="lnkResponse" Runat="server" CommandName="sort" CommandArgument="response">Response</asp:LinkButton>
<asp:Image ID="imgResponse" Runat="server" Visible="False" /><br />
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblResponse" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"response") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle CssClass="pagerstyle" Mode="NumericPages"></PagerStyle>
</asp:datagrid>
Go to Top of Page

tmcgree
Starting Member

4 Posts

Posted - 2008-11-20 : 13:13:57
And here is the stored proc (the ss.ResponseText is being truncated):

CREATE PROC dbo.asp_SurveyGetSnapshot

@SavedFormID int


AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SELECT ss.CategoryTextEnglish AS category,
ss.QuestionText AS question,
CASE WHEN q.AnswerTypeID = 8 THEN
'<a href="Attachment.aspx?AttachmentID=' + CONVERT(VARCHAR(10),ss.AttachmentID) + '" target="_blank"><img src="Images/open.jpg" style="border:0px solid;" alt="View Attachment" /></a>'
ELSE
ss.ResponseText
END AS response
FROM SurveySnapshot ss WITH(NOLOCK)
INNER JOIN Question q ON ss.QuestionID = q.QuestionID
WHERE ss.SavedFormID = @SavedFormID
ORDER BY ss.CategorySequenceID,
ss.QuestionSequenceID
Go to Top of Page
   

- Advertisement -