效果图:
WEB页:
<asp:GridView CssClass="grid" ID="grv" AutoGenerateColumns="False" runat="server"
EnableModelValidation="True" OnRowDataBound="grv_RowDataBound" Width="98%"
onselectedindexchanged="grv_SelectedIndexChanged">
<RowStyle CssClass="rowStyle" Wrap="False" />
<AlternatingRowStyle CssClass="alterStyle" Wrap="False" />
<Columns>
<asp:BoundField HeaderText="序号" />
<asp:BoundField DataField="materialId" HeaderText="物料编号" />
<asp:BoundField DataField="materialName" HeaderText="物料名称" />
<asp:BoundField DataField="Spec" HeaderText="物料描述" />
<%-- <asp:TemplateField HeaderText="设计">
<ItemTemplate>
<asp:TextBox ID="txtDesign" runat="server" Text='<%# Bind("Designer") %>' Width="60px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>--%>
<asp:TemplateField HeaderText="下单数量">
<ItemTemplate>
<asp:TextBox ID="txtTotalNum" runat="server" Text='<%# Bind("TotalCount") %>' Width="60px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="是否有条码">
<ItemTemplate>
<asp:DropDownList ID="ddlIsBarcode" runat="server" Width="50px">
<asp:ListItem Value="0">无</asp:ListItem>
<asp:ListItem Value="1">有</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lblIsBarcode" runat="server" Text='<%# Bind("IsExistsBarcode") %>'
Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="状态">
<ItemTemplate>
<asp:DropDownList ID="ddlIsState" runat="server" Width="60px">
<asp:ListItem Value="0">焊接完</asp:ListItem>
<asp:ListItem Value="1">喷胶完</asp:ListItem>
<asp:ListItem Value="2">老化完</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lblIsPj" runat="server" Text='<%# Bind("IsPj") %>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="goodnum" HeaderText="合格数量" />
<asp:BoundField DataField="repairbacknum" HeaderText="不合格数量" />
<asp:BoundField DataField="confirmor1" HeaderText="检验人" />
<asp:BoundField DataField="confirmDate1" HeaderText="检验日期" DataFormatString="{0:yyyy-MM-dd}" />
<asp:TemplateField HeaderText="下步工序">
<ItemTemplate>
<asp:DropDownList ID="ddlNextStep" runat="server" Width="50px">
<asp:ListItem Value="1">喷胶</asp:ListItem>
<asp:ListItem Value="2">老化</asp:ListItem>
<asp:ListItem Value="3">入库</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lblNextStep" runat="server" Text='<%# Bind("Nextstep") %>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="备 注">
<ItemTemplate>
<asp:TextBox ID="txtMemo" runat="server" Text='<%# Bind("memo") %>' Width="100px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle CssClass="grid_foot" />
</asp:GridView>
designer页:
protected void grv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
#region
string header = "序号#物料编号#物料名称#物料描述#数量#是否有条码#状态#检验结果 合格数量,不合格数量,检验人,检验日期#下步工序#备注";
GridViewTHeaderHepler help = new GridViewTHeaderHepler();
e.Row.CssClass = "fixedHeaderTr";
e.Row.BackColor = System.Drawing.Color.Beige;
help.SplitTableHeader(e.Row, header);
//e.Row.Cells[0].Width = 30;
//e.Row.Cells[1].Width = 110;
//e.Row.Cells[2].Width = 110;
//e.Row.Cells[3].Width = 60;
//e.Row.Cells[4].Width = 30;
//e.Row.Cells[5].Width = 350;
//e.Row.Cells[6].Width = 200;
//e.Row.Cells[7].Width = 90;
//e.Row.Cells[8].Width = 100;
#endregion
} }