关于.net中承接数据的GridView外观问题

本文介绍了如何使用 ASP.NET 中的 GridView 控件进行定制化设置,包括绑定列、模板列的配置,设置列的样式使其居中显示且不换行,并实现鼠标悬停时行背景色变化的效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 绑定列的设置:<HeaderStyle CssClass="title"  HorizontalAlign="Center" />表示标题居中

2 模版列的设置: <ItemTemplate>
                        <asp:LinkButton ID="LB_Modify" CommandName="Modify" Text="修改" runat="server" ></asp:LinkButton>
                        <asp:LinkButton ID="LB_Del" CommandName="Del" Text="删除" runat="server"></asp:LinkButton>
                       
                        </ItemTemplate>
                            <ItemStyle Wrap="False" HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" Width="80px" />
                        
                        </asp:TemplateField>

不换行,居中,并定宽度为80

3 模版列设置超链接 <Columns>
                    <asp:TemplateField>
                    <ItemTemplate>
                    <asp:LinkButton ID="LB_Title" Text='<%# DataBinder.Eval(Container.DataItem,"LC_Title") %>' CommandName="Title" runat="server"></asp:LinkButton>
                   
                    </ItemTemplate>
                    </asp:TemplateField>
                    </Columns>

4 设置鼠标事件,鼠标移动到该条数据变色

e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E4F4FD'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=''");

转载于:https://www.cnblogs.com/yuanweisen/archive/2008/11/20/1337885.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值