asp.net Gridview 的用法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了asp.net Gridview 的用法相关的知识,希望对你有一定的参考价值。

留个档。

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                                    Width="100%"  OnPageIndexChanging="GridView1_PageIndexChanging1" OnRowDeleting="GridView1_RowDeleting"
                                   >
                                    <EmptyDataTemplate>
                                        没有记录
                                    </EmptyDataTemplate>
                                    <PagerSettings Visible="False" />
                                    <RowStyle CssClass="TItem" />
                                    <AlternatingRowStyle CssClass="TItem2" />
                                    <HeaderStyle CssClass="THeader"></HeaderStyle>
                                    <FooterStyle CssClass="TFooder"></FooterStyle>
                                    <Columns>
                                         <asp:TemplateField  HeaderText="生效要求" >
                                            <ItemTemplate>
                                                <%# GetPowerType(DataBinder.Eval(Container.DataItem, "TYPE").ToString())%>
                                             </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="From_STAFFNAME" HeaderText="授权人姓名"></asp:BoundField>
                                        <asp:BoundField DataField="TO_STAFFNAME" HeaderText="被授权人姓名"></asp:BoundField>
                                        <asp:BoundField DataField="TO_STAFFDEPT" HeaderText="被授权人部门"></asp:BoundField>
                                        <asp:BoundField DataField="TO_STAFFDUTY" HeaderText="被授权人职务"></asp:BoundField>
                                        <asp:BoundField DataField="FROM_DATE" HeaderText="生效日期" DataFormatString="{0:yyyy-MM-dd}">
                                            <ItemStyle Width="70px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="TO_DATE" HeaderText="结束日期" DataFormatString="{0:yyyy-MM-dd}" >
                                            <ItemStyle Width="70px" />
                                        </asp:BoundField>
                                         <asp:TemplateField  HeaderText="申请人" >
                                            <ItemTemplate>
                                                <%# GetUserCName(DataBinder.Eval(Container.DataItem, "Creator").ToString())%>
                                             </ItemTemplate>
                                              <ItemStyle Width="60px" />
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="CREATETIME" DataFormatString="{0:yyyy-MM-dd}" HeaderText="创建日期">
                                            <ItemStyle Width="70px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="TaskName" HeaderText="当前节点">
                                            <ItemStyle Width="70px" />
                                        </asp:BoundField>

                                          <asp:TemplateField  HeaderText="流程状态" >
                                            <ItemTemplate>
                                                <%# GetWfStatus(DataBinder.Eval(Container.DataItem, "WfStatus").ToString())%>
                                             </ItemTemplate>
                                        </asp:TemplateField>

                                        <asp:TemplateField HeaderText="详细">
                                            <ItemTemplate>
                                                <a href="OutsidePowerDetail.aspx?Pid=<%# DataBinder.Eval(Container.DataItem, "Pid")%>"
                                                    target="_blank">详细</a>
                                            </ItemTemplate>
                                            <ItemStyle Width="40px" />
                                        </asp:TemplateField>
                                        <asp:TemplateField ShowHeader="False">
                                            <ItemTemplate>
                                            <asp:LinkButton ID="LinkButton1" OnClientClick="return confirm(‘您确认删除该记录吗?‘);" runat="server" CausesValidation="False"
                                            CommandName="Delete" Text="删除"></asp:LinkButton>
                                            </ItemTemplate>
                                            </asp:TemplateField>

                                    </Columns>
                                </asp:GridView>

以上是关于asp.net Gridview 的用法的主要内容,如果未能解决你的问题,请参考以下文章

asp.net的gridview控件问题

asp.net c# gridview的居中问题

ASP.NET GridView代码实现编辑,删除功能

asp.net c#在gridview添加dropdownlist

Asp.net中GridView使用详解(引)

asp.net中GridView怎样进行分页,编辑,删除操作