日期:2014-05-19  浏览次数:20427 次

还是datagrid的问题,有关于前台显示代码的,都看看啊~20分表心意~
我是这样写的:

<asp:DataGrid
AllowPaging= "true "
AutoGenerateColumns= "False "
AllowSorting= "True "
OnSortCommand= "dgsort "
PageSize= "8 "
PagerStyle-Mode= "NumericPages "
CssClass= "gridcss "
OnPageIndexChanged= "tochange "
Headerstyle-BackColor= "#666666 "
AlternatingItemStyle-BackColor= "#999999 "
CellSpacing= "2 "
CellPadding= "5 "
border= "0 "
ID= "mygrid "
runat= "server ">
<Columns>
<asp:BoundColumn   SortExpression= "biaoti "   HeaderText= "标   题 "   DataField= "biaoti "> </asp:BoundColumn>
<asp:BoundColumn   SortExpression= "shijian "   HeaderText= "时   间 "   DataField= "shijian "   > </asp:BoundColumn>
</Columns>
</asp:DataGrid>


我看着还有人写法更灵活:

<asp:datagrid   id= "DataGrid1 "   style= "Z-INDEX:   102;   LEFT:   16px;   WORD-BREAK:   break-all;   POSITION:   absolute;   TOP:   88px "  
runat= "server "   HorizontalAlign= "Left "   ForeColor= "Blue "   BorderColor= "#8080FF "   PageSize= "20 "  
AutoGenerateColumns= "False "   AllowPaging= "True "   ShowFooter= "True "   Width= "856px "   Font-Size= "10pt ">  
<FooterStyle   Font-Size= "10pt "   ForeColor= "Transparent "   VerticalAlign= "Top "> </FooterStyle>  
<SelectedItemStyle   Font-Size= "10pt "> </SelectedItemStyle>  
<EditItemStyle   Font-Size= "10pt "> </EditItemStyle>  
<AlternatingItemStyle   Font-Size= "10pt "> </AlternatingItemStyle>  
<HeaderStyle   HorizontalAlign= "Center "   VerticalAlign= "Top "> </HeaderStyle>  
<Columns>  
<asp:TemplateColumn>  
<ItemStyle   HorizontalAlign= "Center "   VerticalAlign= "Middle "> </ItemStyle>
<HeaderTemplate>  


。。。。。


</HeaderTemplate>  
<ItemTemplate>  

。。。。。。

<asp:Label   ID= "lblCode "   Text= ' <%#   DataBinder.Eval(Container.DataItem,   "code ")   %> '   Runat=server   />


</ItemTemplate>  
<FooterTemplate>  
<font   color= "blue "> </font> </table>  
</FooterTemplate>  
</asp:TemplateColumn>  
</Columns>  
<PagerStyle   NextPageText= "次ページ→ "   Font-Size= "10pt "   BorderColor= "Transparent "   PrevPageText= "←前ページ "  
HorizontalAlign= "Right "   Mode= "NumericPages "> </PagerStyle>  
</asp:datagrid>


请问我想限制列的宽度和字符的显示个数并加上...来显示标题该如何取舍啊?用哪种比较好啊?我个人对第2种写法不是很了解,希望能得到先驱们的指引~

------解决方案--------------------
用下一中,模板列的形式
------解决方案--------------------
用第二种啦.
不理解可以