网格视图弹出框

时间:2015-03-05 13:33:55

标签: c# asp.net

我在asp页面中有一个网格视图。它有一个只读数量的字段加上两个更新字段,数量好,数量报废。我想要做的是有一个弹出的构造,说他们确定他们想要更新记录。然后,如果更新数量的商品数量大于数量的120%,或者更新数量商品加上报废的更新数量比弹出第二个构造箱的数量大120%。

我对这一切都很陌生,所以请温柔地解释。我已经到目前为止,但很难将更新的数量用于代码(C#)。

非常感谢

马特

这是一个网格视图。

        <asp:GridView ID="GridView1"  runat="server" AutoGenerateColumns="False" DataKeyNames="wona,wopnumber" DataSourceID="SqlDataSource2" AllowPaging="True" AllowSorting="True" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal" PageSize="20" OnRowDataBound="GridView1_RowDataBound">
        <AlternatingRowStyle BackColor="#F7F7F7" />
        <Columns>
            <asp:TemplateField ShowHeader="False" >
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update" OnClientClick="return confirm('Are you sure you want to update this ?');"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"></asp:LinkButton>
                </ItemTemplate>
                <ItemStyle Font-Size="x-Large"/>
            </asp:TemplateField>
            <asp:HyperLinkField HeaderText="Route Card" Text="Route Card"  DataNavigateUrlFields="wona,wopnumber" DataNavigateUrlFormatString="~/OpUpdate/RouteCard.aspx?wona={0}&wopnumber={1}" >
            <ItemStyle Font-Size="x-Large" />
            </asp:HyperLinkField>
            <asp:BoundField DataField="wona" HeaderText="WO No" ReadOnly="True" SortExpression="wona" >
            <ItemStyle Font-Size="Large" />
            </asp:BoundField>
            <asp:BoundField DataField="wopnumber" HeaderText="Op No" ReadOnly="True" SortExpression="wopnumber" >
            <ItemStyle Font-Size="Medium" />
            </asp:BoundField>
            <asp:BoundField DataField="wqordered" HeaderText="Qty Ord" SortExpression="wqordered" ReadOnly="True" >
            <ItemStyle Font-Size="x-Large" Font-Bold="True" />
            </asp:BoundField>
            <asp:BoundField DataField="wqscrapped" HeaderText="Scrppd" SortExpression="wqscrapped" DataFormatString="{0:R}" >
            <ItemStyle Font-Size="x-Large" />
            </asp:BoundField>
            <asp:BoundField DataField="wqgood" HeaderText="Good" SortExpression="wqgood" DataFormatString="{0:R}" >
            <ItemStyle Font-Size="x-Large" />
            </asp:BoundField>
            <asp:HyperLinkField DataNavigateUrlFields="partid" HeaderText="Part No" DataNavigateUrlFormatString="http://webserver01.haigh.local:8084/CadDrawing/CadDrawing.aspx?partid={0}" DataTextField="partid" />
            <asp:BoundField DataField="duedate" HeaderText="Due Date" ReadOnly="True" SortExpression="duedate" >
            <ItemStyle Font-Size="x-Large" />
            </asp:BoundField>
            <asp:BoundField DataField="priority" HeaderText="Priority" ReadOnly="True" SortExpression="priority">
            <ItemStyle Font-Size="x-Large" HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="partdesc" HeaderText="Description" SortExpression="partdesc" ReadOnly="True" >
            <ItemStyle Font-Size="Small" />
            </asp:BoundField>
            <asp:BoundField DataField="materialgroup" HeaderText="Mat Grp" ReadOnly="True" SortExpression="materialgroup" />
            <asp:BoundField DataField="opstatus" HeaderText="opstatus" ReadOnly="True" SortExpression="opstatus" ItemStyle-CssClass="collapse"  >
            <HeaderStyle CssClass="collapse" />
            <ItemStyle CssClass="collapse"></ItemStyle>
            </asp:BoundField>
            <asp:ImageField HeaderText="OP" ReadOnly="True" >
            </asp:ImageField>
            <asp:BoundField DataField="kitstatus" HeaderText="kitstatus" ReadOnly="True" SortExpression="kitstatus" ItemStyle-CssClass="collapse" >
            <HeaderStyle CssClass="collapse" />
            <ItemStyle CssClass="collapse"></ItemStyle>
            </asp:BoundField>
            <asp:ImageField HeaderText="Kit" ReadOnly="True">
            </asp:ImageField>
            <asp:BoundField DataField="matstatus" HeaderText="matstatus" SortExpression="matstatus" ReadOnly="True" ItemStyle-CssClass="collapse" >
            <HeaderStyle CssClass="collapse" />
            <ItemStyle CssClass="collapse"></ItemStyle>
            </asp:BoundField>
            <asp:ImageField HeaderText="Mat" ReadOnly="True">
            </asp:ImageField>
        </Columns>
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <SortedAscendingCellStyle BackColor="#F4F4FD" />
        <SortedAscendingHeaderStyle BackColor="#5A4C9D" />
        <SortedDescendingCellStyle BackColor="#D8D8F0" />
        <SortedDescendingHeaderStyle BackColor="#3E3277" />
    </asp:GridView>

背后的代码

public partial class OpUpdate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlDataSource2.UpdateParameters["aduser"].DefaultValue = User.Identity.Name.ToString();
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[12].Text == "Grn")
            {
                e.Row.Cells[13].Attributes.Add("Style", "background: url(../Images/Grn.png) no-repeat center;");

            }
            if (e.Row.Cells[12].Text == "Ambr")
            {
                e.Row.Cells[13].Attributes.Add("Style", "background: url(../Images/Ambr.png) no-repeat  center;");

            }
            if (e.Row.Cells[12].Text == "Red")
            {
                e.Row.Cells[13].Attributes.Add("Style", "background: url(../Images/Red.png) no-repeat  center;");

            }
            if (e.Row.Cells[14].Text == "Grn")
            {
                e.Row.Cells[15].Attributes.Add("Style", "background: url(../Images/Grn.png) no-repeat center;");

            }
            if (e.Row.Cells[14].Text == "Ambr")
            {
                e.Row.Cells[15].Attributes.Add("Style", "background: url(../Images/Ambr.png) no-repeat  center;");

            }
            if (e.Row.Cells[14].Text == "Red")
            {
                e.Row.Cells[15].Attributes.Add("Style", "background: url(../Images/Red.png) no-repeat  center;");

            }
            if (e.Row.Cells[16].Text == "Grn")
            {
                e.Row.Cells[17].Attributes.Add("Style", "background: url(../Images/Grn.png) no-repeat center;");

            }
            if (e.Row.Cells[16].Text == "Ambr")
            {
                e.Row.Cells[17].Attributes.Add("Style", "background: url(../Images/Ambr.png) no-repeat  center;");

            }
            if (e.Row.Cells[16].Text == "Red")
            {
                e.Row.Cells[17].Attributes.Add("Style", "background: url(../Images/Red.png) no-repeat  center;");

            }
            if (e.Row.Cells[16].Text == "Blu")
            {
                e.Row.Cells[17].Attributes.Add("Style", "background: url(../Images/Blu.png) no-repeat  center;");
            }
        }
    }
}

0 个答案:

没有答案