나는 asp.net 웹 페이지에서 gridview 있습니다. 데이터 소스에는 SQL Server 테이블이 있습니다. 각 셀의 최대 길이가 50 미만이 되길 원합니다. 오류가 있습니다.데이터 바인딩 구문 오류
고맙습니다. 고맙습니다.
<asp:TemplateField HeaderText="OrgContactName" SortExpression="OrgContactName">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("OrgContactName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# (Eval("OrgContactName").Length>50)?Eval("OrgContactName").SubString(0,50):Eval("OrgContactName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
오류 :.. 당신이 캐스팅 할 필요가 있으므로
Compiler Error Message: CS1061: 'object' does not contain a definition for 'Length' and no extension method 'Length' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
분명히 TemplateField는 Length 속성을 가질 수 없습니다. 또는 적어도 Eval ("OrgContactName") 일 수도 있습니다. Text.Length.을 사용하여 을 변경할 수 있습니까? –