GridView

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                                                     AutoGenerateColumns="False" CellPadding="4" DataKeyNames="MOrderID" DataSourceID="OrderSqlDataSource"
                                                     ForeColor="#333333" GridLines="None" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound"  >
                                                     <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                                     <Columns>
                                                         <asp:TemplateField>
                                                             <ItemTemplate>
                                                                 <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "~/Customer/Question_server.aspx?id=" + Eval("MOrderID") %>' Text="用户反馈" ></asp:HyperLink>
                                                             </ItemTemplate>
                                                         </asp:TemplateField>
                                                         <asp:BoundField DataField="MOrderID" HeaderText="订单号" InsertVisible="False" ReadOnly="True"
                                                             SortExpression="MOrderID" />
                                                         <asp:BoundField DataField="MCreateDate" HeaderText="订单时间" SortExpression="MCreateDate" />
                                                         <asp:BoundField DataField="MContact" HeaderText="收货人" SortExpression="MContact" />
                                                         <asp:TemplateField HeaderText="订单金额" SortExpression="MAmount">
                                                             <EditItemTemplate>
                                                                 <asp:Label ID="Label1" runat="server" Text='<%# Eval("MAmount") %>'></asp:Label>
                                                             </EditItemTemplate>
                                                             <ItemTemplate>
                                                                 <asp:Label ID="Label1" runat="server" Text='<%# Bind("MAmount") %>'></asp:Label>
                                                             </ItemTemplate>
                                                         </asp:TemplateField>
                                                         <asp:TemplateField HeaderText="查阅">
                                                             <ItemTemplate>
                                                                 <asp:ImageButton ID="ImageButton1" runat="server" PostBackUrl='<%# "~/Customer/Order_detail.aspx?id=" + Eval("MOrderID") %>'  ImageUrl="~/images/magnifier.gif" />
                                                             </ItemTemplate>                     
                                                         </asp:TemplateField>
                                                         <asp:TemplateField HeaderText="订单状态" SortExpression="MAmount">
                                                             <EditItemTemplate>
                                                                 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                                             </EditItemTemplate>
                                                             <ItemTemplate>
                                                                 <asp:Label ID="LblState" runat="server" Text='<%# Eval("MStepState") %>'></asp:Label>
                                                             </ItemTemplate>
                                                         </asp:TemplateField>
                                                         <asp:BoundField  HeaderText="出库时间" SortExpression="MAmount" />
                                                         <asp:TemplateField ShowHeader="False">
                                                             <ItemTemplate>
                                                                 <asp:LinkButton ID="LblCancel" runat="server" CausesValidation="False"
                                                                    Text="撤单" CommandName="Cancel" CommandArgument='<%# GridView1.Rows.Count %>' Enabled='<%# Convert.ToBoolean(Eval("MIsEnable")) %>'    ></asp:LinkButton>
                                                             </ItemTemplate>
                                                         </asp:TemplateField>
                                                        
                                                     </Columns>
                                                     <RowStyle BackColor="#EFF3FB" />
                                                     <EditRowStyle BackColor="#2461BF" />
                                                     <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                                     <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                                                     <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                                     <AlternatingRowStyle BackColor="White" />
                                                 </asp:GridView>
                                                 <asp:SqlDataSource ID="OrderSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:LabelEasyConnectionString %>"
                                                     SelectCommand="SELECT CASE WHEN dbo.tOrder.MStep=3 THEN 'false' ELSE 'true' END AS MIsEnable , SUM(dbo.tOrderDetail.MPrice * dbo.tOrderDetail.MQuantity) AS MAmount,dbo.tOrder.MOrderID , dbo.tOrder.MCreateDate,dbo.tStepState.MStepState ,dbo.tOrder.MContact FROM dbo.tStepState INNER JOIN dbo.tOrder ON dbo.tStepState.MStep = dbo.tOrder.MStep INNER JOIN dbo.tOrderDetail ON dbo.tOrder.MOrderID = dbo.tOrderDetail.MOrderID WHERE ([MMemberID] = @MMemberID) group by  dbo.tOrder.MOrderID , dbo.tOrder.MCreateDate ,dbo.tOrder.MContact,dbo.tStepState.MStepState,dbo.tOrder.MStep "
                                                     >
                                                    
                                                     <SelectParameters>
                                                        <asp:SessionParameter Name="MMemberID" SessionField="MemberID" Type="Int32" />
                                                    </SelectParameters>
                                                 </asp:SqlDataSource>

web.config
 <connectionStrings>
  <add name="LabelEasyConnectionString" connectionString="Data Source=;Initial Catalog=;User ID=sa;Password="
   providerName="System.Data.SqlClient" />
 
 </connectionStrings>




 

你可能感兴趣的:(GridView)