控制DataGrid列样式(列宽,行颜色)

 我来答
haoyuzhou009
2006-11-09 · TA获得超过493个赞
知道小有建树答主
回答量:440
采纳率:0%
帮助的人:156万
展开全部
<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>
<table border="1">
<tr bordercolor="#00FFFF" bgcolor="00FFFF">
<td rowspan="1" width="50"></td>
<td width="120"></td>
<td width="100"></td>
<td width="100"></td>
<td width="130"></td>
<td width="130"></td>
<td width="140"></td>
<td width="50"></td>
</tr>
<tr align="center" bordercolor="#d0d0ee" bgcolor="Gainsboro">
<td rowspan="3" width="50"><span style="font-size=13;font-family:'MS UI Gothic'"><nobr><strong>写真</strong></nobr></span></td>
<td width="120"><span style="font-size:13;font-family:'MS UI Gothic' "><nobr><strong>C D</strong></nobr></span></td>
<td width="100"><span style="FONT-SIZE: 13;font-family:'MS UI Gothic'"><nobr><strong>所属</strong></nobr></span></td>
<td width="100"><span style="FONT-SIZE: 13;font-family:'MS UI Gothic'"><nobr><strong>担当</strong></nobr></span></td>
<td width="130"><nobr><span style="FONT-SIZE: 13;font-family: 'MS UI Gothic'"><nobr><strong>连络先1</strong></nobr></span></nobr></td>
<td width="130"><nobr><span style="FONT-SIZE: 13;font-family: 'MS UI Gothic'"><nobr><strong>连络先2</strong></nobr></span></nobr></td>
<td width="190" align="center" colspan="2"><span style="FONT-SIZE: 13;font-family:'MS UI Gothic'"><nobr><strong>メールアドレス</strong></nobr></span></td>
</tr>
<tr align="center" bordercolor="#d0d0ee" bgcolor="Gainsboro">
<td width="120" rowspan="2"><span style="font-size=13;font-family:'MS UI Gothic'"><strong>社员名</strong></span></td>
<td width="100" rowspan="2"><span style="font-size=13;font-family:'MS UI Gothic'"><strong>社员区分</strong></span></td>
<td width="100" rowspan="2"><span style="font-size=13;font-family:'MS UI Gothic'"><strong>グルーピング</strong></span></td>
<td width="130" rowspan="2"><span style="font-size=13;font-family:'MS UI Gothic'"><strong>グループ入社日</strong></span></td>
<td width="270" rowspan="2" colspan="2"><span style="font-size=13;font-family:'MS UI Gothic'"><strong>备考</strong></span></td>
<td width="50" rowspan="2"><span style="font-size=13;font-family:'MS UI Gothic'"><br>
</span>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bordercolordark="#d0d0ee" style="FONT-FAMILY: 'MS UI Gothic'" height="36px" valign="middle"
style="BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none">
<td rowspan="3"><a href='../Image/<%# DataBinder.Eval(Container.DataItem, "addendum") %>'><img ="50px" width=50px height=100% src='<%# DataBinder.Eval(Container.DataItem, "addendum","../Image/{0}") %>'></a></asp:Image><br>
</td>
<td align="center"><span style="font-size:14px"><nobr>
<asp:Label ID="lblCode" Text='<%# DataBinder.Eval(Container.DataItem, "code") %>' Runat=server /></nobr> </span></td>
<td><span style="font-size:14px"><nobr><%# DataBinder.Eval(Container.DataItem, "long_name1") %>
  </nobr></span>
</td>
<td><span style="font-size:14px"><nobr><%# DataBinder.Eval(Container.DataItem, "long_name2") %>
  </nobr></span>
</td>
<td><span style="font-size:14px"><%# DataBinder.Eval(Container.DataItem, "contact1") %><br>
</span>
</td>
<td><span style="font-size:14px"><%# DataBinder.Eval(Container.DataItem, "contact2") %><br>
</span>
</td>
<td colspan="2"><a href ='mailto:<%# DataBinder.Eval(Container.DataItem, "mail_address") %>'><span style="font-size:14px"><%# DataBinder.Eval(Container.DataItem, "mail_address") %><br>
</span></a>
</td>
</tr>
<tr bordercolordark="#d0d0ee" style="FONT-FAMILY: 'MS UI Gothic'" height="35px">
<td align="center" rowspan="2">
<asp:LinkButton Runat="server" CommandName="lbn" ID="Button2">
<span style="font-size:14px">
<%# DataBinder.Eval(Container.DataItem, "name") %>
</span>
</asp:LinkButton></td>
<td rowspan="2"><span style="font-size:14px"><nobr><%# DataBinder.Eval(Container.DataItem, "employeetype") %> 
</nobr></span>
</td>
<td rowspan="2"><span style="font-size:14px"><%# DataBinder.Eval(Container.DataItem, "grouping") %><br>
</span>
</td>
<td rowspan="2"><span style="font-size:14px"><%# DataBinder.Eval(Container.DataItem, "initiationtogroup" ,"{0:yyyy年M月}")%><br>
</span>
</td>
<td rowspan="2" colspan="2"><span style="font-size:14px"><%# DataBinder.Eval(Container.DataItem, "remarks") %><br>
</span>
</td>
<td rowspan="2" align="center"><span style="width=60">
<asp:Button CommandName="Modify" Text="修正" Runat="server" ID="Button1"></asp:Button></span></td>
</tr>
</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>

这是段比较经典的代码 你看懂了 大概对datagrid会有更深刻的了解~
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式