各种前台绑定

来源:互联网 发布:新浪期货数据接口api 编辑:程序博客网 时间:2024/06/05 20:45

记录,以便使用

1、GridView 中列

<asp:TemplateField HeaderText="<%$ Resources:LexmarkMpsDoa,Field_BillCo %>">
    <ItemTemplate>
      <asp:Label ID="lblArea" runat="server" Text='<%# Bind("Printer_DoaCo") %>'></asp:Label>
   </ItemTemplate>
<ItemStyle HorizontalAlign="Left" Wrap="false" />
</asp:TemplateField>

2、绑定资源文件

上述中的<asp:TemplateField HeaderText="<%$ Resources:LexmarkMpsDoa,Field_BillCo %>">为一种

直接写到td中的:<%=Resources.LexmarkMpsDoa.Field_PrinterPartNo%>

3、Text='<%#DataBinder.Eval(Container.DataItem,"EntrustCo")%>'

4、时间格式:<asp:BoundField DataField ="Birthday" HeaderText ="生日" DataFormatString ="{0:yyyy-MM-dd}"/>

5、  模板列时间格式

     <asp:TemplateField HeaderText="提交时间">
                  <ItemTemplate>
                   <asp:Label ID="lblCategory" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"EndDate","{0:yyyy-MM-dd}") %>'></asp:Label>
                       </ItemTemplate>
                    <ItemStyle HorizontalAlign="Left" Wrap="false" />
           </asp:TemplateField>

6、字符处理:<asp:Label ID="lblCusName" runat="server" Text='<%# (bool)Eval("IsTrusted")?"先发后返":"先返后发" %>'></asp:Label>

7、绑定RowNo:   <asp:LinkButton ID="BtnDetails" runat="server" CommandArgument=<%#((GridViewRow) Container).RowIndex %> CommandName="Details" Text="<%$ Resources:LexmarkMpsDoa,Identity_View %>"></asp:LinkButton>

   <asp:Label ID="lb_NO" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Label>

8、格式化模板列

<asp:TemplateField HeaderText="<%$ Resources:LexmarkMpsDoa,Field_ReceiveDate %>">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblReceiveDate" runat="server" Text='<%# string.Format("{0:yyyy-MM-dd HH:MM:ss}", Eval("ReceiveDate")) %> '></asp:Label>
                                                        </ItemTemplate>
                                                        <ItemStyle HorizontalAlign="Left" Wrap="false" />
                                                    </asp:TemplateField>

9、获取客户端Id

     document.getElementById("<%=BtnRefreshUpload.ClientID %>").click();

原创粉丝点击