Grideview前台:
1 <DIV class="mainDiv" id="GridWidth"> 2 <ASP:GridView id="GridView1" runat="server" CssClass="GridViewStyle" Width="100%" ShowFooter="true" DataKeyField="CT01002" AutoGenerateColumns="false" OnRowDataBound="Gridview1_DataBound" > 3 <HeaderStyle CssClass="GridViewHeaderStyle"></HeaderStyle> 4 <RowStyle CssClass="GridViewRowStyle" /> 5 <FooterStyle CssClass="GridViewFooterStyle"/> 6 <Columns> 7 <asp:BoundField HeaderText="派车单流水号" DataField="CT01002" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" HtmlEncode="false" Visible=false></asp:BoundField> 8 <asp:TemplateField HeaderText="序号" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"> 9 <ItemTemplate> 10 <%# Container.DataItemIndex+1%> 11 </ItemTemplate> 12 </asp:TemplateField> 13 <%-- <asp:BoundField HeaderText="系统编号" DataField="SL03003" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundField>--%> 14 <asp:TemplateField HeaderText="系统编号" HeaderStyle-Wrap="False" Visible="true"> 15 <ItemTemplate> 16 <a class="Micro-12-blue" onClick='window.open("../qq.aspx?sn=<%# DataBinder.Eval(Container.DataItem, "CT01002") %>","carton_change","left=50,top=50,width=1250,height=700,directories=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no,resizable=yes");return false'> 17 <asp:Label ID="IF_VALID1" runat="server" Text='<%# Bind("SL03003") %>'></asp:Label> 18 </a> 19 </ItemTemplate> 20 </asp:TemplateField> 21 <asp:BoundField HeaderText="箱号" DataField="CT01005" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundField> 22 <%--<asp:BoundField HeaderText="派车单号" DataField="DD04028" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundField>--%> 23 <asp:TemplateField HeaderText="派车单号" HeaderStyle-Wrap="False" Visible="true"> 24 <ItemTemplate> 25 <a class="Micro-12-blue" onClick='window.open("../ww.aspx?sn=<%# DataBinder.Eval(Container.DataItem, "CT01002") %>","carton_change","left=50,top=50,width=1250,height=700,directories=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no,resizable=yes");return false'> 26 <asp:Label ID="IF_VALID" runat="server" Text='<%# Bind("DD04028") %>'></asp:Label> 27 </a> 28 </ItemTemplate> 29 </asp:TemplateField> 30 <asp:BoundField HeaderText="派车日期" DataField="DD04003" DataFormatString="{0:yyyy-MM-dd}" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundField> 31 <asp:BoundField HeaderText="车号" DataField="DD04004" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundField> 32 <asp:BoundField HeaderText="驾驶员" DataField="DD04005" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundField> 33 <asp:BoundField HeaderText="车队名称" DataField="SL01002" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundField> 34 <%--<asp:BoundField HeaderText="统计里程" DataField="DD04030" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign=Right></asp:BoundField>--%> 35 <asp:BoundField HeaderText="装卸门点" DataField="CT01018" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundField> 36 <asp:BoundField HeaderText="港区" DataField="OR01110" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundField> 37 <asp:BoundField HeaderText="业务归属" DataField="CT01021" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundField> 38 <asp:BoundField HeaderText="出车费" DataField="COST_NAME" DataFormatString="{0:#,##0.00}" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign=Right></asp:BoundField> 39 <asp:BoundField HeaderText="运输费" DataField="COST_YUNSHU" DataFormatString="{0:#,##0.00}" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign=Right></asp:BoundField> 40 <asp:BoundField HeaderText="亏盈金额" DataField="Exhibit_amount" DataFormatString="{0:#,##0.00}" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign=Right></asp:BoundField> 41 </Columns> 42 </ASP:GridView></DIV>
后台:
1 public void Gride_List() 2 { 3 #region 判断条件不能全部为空 4 5 if (CT01005.Text.Trim() == "" && DD04004.Text.Trim() == "" && DD04005.Text.Trim() == "" && SL01002.Text.Trim() == "" 6 && DD04003F.Value.Trim() == "" && DD04003T.Value.Trim() == "") 7 { 8 Message.Text = "查询条件不能全部为空!!!"; 9 Message.Style["color"] = "red"; 10 return; 11 } 12 #endregion 13 Message.Text = ""; 14 15 String myCommand = "EXEC yunshu_cost_ as@CT01005,@DD04004,@DD04005,@SL01002,@DD04003F,@DD04003T,@CT01021"; 16 SqlParameter[] parameters = { 17 new SqlParameter("@CT01005", SqlDbType.NVarChar, 50) 18 ,new SqlParameter("@DD04004", SqlDbType.NVarChar, 50) 19 ,new SqlParameter("@DD04005", SqlDbType.NVarChar, 50) 20 ,new SqlParameter("@SL01002", SqlDbType.NVarChar, 50) 21 ,new SqlParameter("@DD04003F", SqlDbType.NVarChar, 50) 22 ,new SqlParameter("@DD04003T", SqlDbType.NVarChar, 50) 23 ,new SqlParameter("@CT01021", SqlDbType.NVarChar, 50) 24 }; 25 26 int p = 0; parameters[p].Value = CT01005.Text.Trim(); 27 p++; parameters[p].Value = DD04004.Text.Trim(); 28 p++; parameters[p].Value = DD04005.Text.Trim(); 29 p++; parameters[p].Value = SL01002.Text.Trim(); 30 p++; parameters[p].Value = DD04003F.Value.Trim(); 31 p++; parameters[p].Value = DD04003T.Value.Trim(); 32 p++; parameters[p].Value = CT01021.SelectedValue.Trim(); 33 DataSet ds = new DataSet(); 34 try 35 { 36 ds = DbHelperSQL.Query(myCommand.ToString(), parameters); 37 GridView1.DataSource = ds.Tables["ds"]; 38 GridView1.DataBind(); 39 // AC.GridViewDataBind(this.GridView1, ds.Tables["ds"]); 40 41 } 42 catch (Exception err) 43 { 44 ScriptManager.RegisterStartupScript(this.GridView1, this.GetType(), "pop", "$.ligerDialog.error('系统错误:" + err.Message.Replace(" ", "").Replace(" ", "").Replace("'", "") + "');", true); 45 } 46 }
DataGrid前台:
1 <DIV id="GridWidth1" class="mainDiv1"><ASP:DATAGRID id="Datagrid1" runat="server" Width="100%" BorderColor="#ffffff" AutoGenerateColumns="false" DataKeyField="CT01002" OnRowDataBound="Gridview1_DataBound" ItemStyle-CssClass="Micro-12-black" ShowFooter="false" BackColor="#fffff2" CellPadding="3" CellSpacing="0" BorderStyle="None"> 2 <HeaderStyle Font-Bold="True" ForeColor="#fffff2" BackColor="#214a87"></HeaderStyle> 3 <ItemStyle CssClass="GridViewRowStyle" /> 4 <Columns> 5 <%-- dd04002 --%> 6 <asp:BoundColumn HeaderText="派车单流水号" DataField="CT01002" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" Visible="false"></asp:BoundColumn> 7 <asp:TemplateColumn HeaderText="序号" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"> 8 <ItemTemplate> 9 <%# Container.ItemIndex+1%> 10 </ItemTemplate> 11 </asp:TemplateColumn> 12 13 <asp:TemplateColumn HeaderText="系统编号" HeaderStyle-Wrap="False" Visible="true"> 14 <ItemTemplate> 15 <%-- ?division=<%# DataBinder.Eval(Container.DataItem, "OR01003") %>&sn=<%# DataBinder.Eval(Container.DataItem, "OR01001") %>&ft=1" target="_blank"--%> 16 17 <a class="Micro-12-blue" href="" onClick='window.open("ss.aspx?sn=<%# DataBinder.Eval(Container.DataItem, "CT01002") %>","carton_change","left=50,top=50,width=1250,height=700,directories=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no,resizable=yes");return false'> 18 <%# DataBinder.Eval(Container.DataItem, "SL03003") %> 19 </a> 20 </ItemTemplate> 21 </asp:TemplateColumn> 22 <asp:BoundColumn HeaderText="箱号" DataField="CT01005" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundColumn> 23 <asp:TemplateColumn HeaderText="派车单号" HeaderStyle-Wrap="False" Visible="true"> 24 <ItemTemplate> 25 <a class="Micro-12-blue" href="" onClick='window.open("ss.aspx?sn=<%# DataBinder.Eval(Container.DataItem, "CT01002") %>","carton_change","left=50,top=50,width=1250,height=700,directories=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no,resizable=yes");return false'> 26 <%# DataBinder.Eval(Container.DataItem, "DD04028") %> 27 </a> 28 </ItemTemplate> 29 </asp:TemplateColumn> 30 <asp:BoundColumn HeaderText="派车日期" DataField="DD04003" DataFormatString="{0:yyyy-MM-dd}" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundColumn> 31 <asp:BoundColumn HeaderText="车号" DataField="DD04004" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundColumn> 32 <asp:BoundColumn HeaderText="驾驶员" DataField="DD04005" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundColumn> 33 <asp:BoundColumn HeaderText="车队名称" DataField="SL01002" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"></asp:BoundColumn> 34 <%--<asp:BoundColumn HeaderText="统计里程" DataField="DD04030" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign=Right></asp:BoundColumn> --%> 35 <asp:BoundColumn HeaderText="出车费" DataField="COST_NAME" DataFormatString="{0:#,##0.00}" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign=Right></asp:BoundColumn> 36 <asp:BoundColumn HeaderText="运输费" DataField="COST_YUNSHU" DataFormatString="{0:#,##0.00}" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign=Right></asp:BoundColumn> 37 <asp:BoundColumn HeaderText="亏盈金额" DataField="Exhibit_amount" DataFormatString="{0:#,##0.00}" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign=Right></asp:BoundColumn> 38 </Columns> 39 </ASP:DATAGRID></DIV>
后台:
1 public void Gride_List1() 2 { 3 #region 判断条件不能全部为空 4 if (CT01005.Text.Trim() == "" && DD04004.Text.Trim() == ""&&DD04005.Text.Trim() == "" && SL01002.Text.Trim() == "" 5 && DD04003F.Value.Trim() == "" && DD04003T.Value.Trim() == "") 6 { 7 Message.Text = "查询条件不能全部为空!!!"; 8 Message.Style["color"] = "red"; 9 return; 10 } 11 #endregion 12 Message.Text = ""; 13 SqlDataAdapter myCommand = new SqlDataAdapter("EXEC yunshu_cost_qq@CT01005,@DD04004,@DD04005,@SL01002,@DD04003F,@DD04003T", connection); 14 15 myCommand.SelectCommand.Parameters.Add(new SqlParameter("@CT01005", System.Data.SqlDbType.NVarChar, 30)); 16 myCommand.SelectCommand.Parameters["@CT01005"].Value = CT01005.Text.Trim(); 17 18 myCommand.SelectCommand.Parameters.Add(new SqlParameter("@DD04004", System.Data.SqlDbType.NVarChar, 30)); 19 myCommand.SelectCommand.Parameters["@DD04004"].Value = DD04004.Text.Trim(); 20 21 myCommand.SelectCommand.Parameters.Add(new SqlParameter("@DD04005", System.Data.SqlDbType.NVarChar, 30)); 22 myCommand.SelectCommand.Parameters["@DD04005"].Value = DD04005.Text.Trim(); 23 24 myCommand.SelectCommand.Parameters.Add(new SqlParameter("@SL01002", System.Data.SqlDbType.NVarChar, 30)); 25 myCommand.SelectCommand.Parameters["@SL01002"].Value = SL01002.Text.Trim(); 26 27 myCommand.SelectCommand.Parameters.Add(new SqlParameter("@DD04003F", System.Data.SqlDbType.NVarChar, 30)); 28 myCommand.SelectCommand.Parameters["@DD04003F"].Value = DD04003F.Value.Trim(); 29 30 myCommand.SelectCommand.Parameters.Add(new SqlParameter("@DD04003T", System.Data.SqlDbType.NVarChar, 30)); 31 myCommand.SelectCommand.Parameters["@DD04003T"].Value = DD04003T.Value.Trim(); 32 33 DataSet ds = new DataSet(); 34 myCommand.Fill(ds, "操作录入"); 35 36 Datagrid1.DataSource = ds.Tables["操作录入"].DefaultView; 37 Datagrid1.DataBind(); 38 39 //try 40 //{ 41 // ds = DbHelperSQL.Query(myCommand.ToString(), parameters); 42 // AC.GridViewDataBind(this.GridView1, ds.Tables["ds"]); 43 44 //} 45 //catch (Exception err) 46 //{ 47 // ScriptManager.RegisterStartupScript(this.GridView1, this.GetType(), "pop", "$.ligerDialog.error('系统错误:" + err.Message.Replace(" ", "").Replace(" ", "").Replace("'", "") + "');", true); 48 //} 49 }