62,046
社区成员
发帖
与我相关
我的任务
分享
<asp:GridView ID="gdv" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" OnDataBound="gdv_DataBound" OnRowDeleting="gdv_RowDeleting" OnRowEditing="gdv_RowEditing" OnRowCancelingEdit="gdv_RowCancelingEdit" OnRowUpdating="gdv_RowUpdating">
<FooterStyle BackColor="White" ForeColor="#000066" />
<RowStyle ForeColor="#000066" />
<Columns>
<asp:BoundField DataField="su_Name" HeaderText="名 称" >
<HeaderStyle CssClass="gdvtop" />
</asp:BoundField>
<asp:BoundField DataField="su_Address" HeaderText="地 址" >
<HeaderStyle CssClass="gdvtop" />
</asp:BoundField>
<asp:BoundField DataField="su_Contact" HeaderText="联系人" >
<HeaderStyle CssClass="gdvtop" />
</asp:BoundField>
<asp:BoundField DataField="su_Phone" HeaderText="联系电话" >
<HeaderStyle CssClass="gdvtop" />
</asp:BoundField>
<asp:BoundField DataField="su_MobilePhone" HeaderText="移动电话" >
<HeaderStyle CssClass="gdvtop" />
</asp:BoundField>
<asp:BoundField DataField="su_Remark" HeaderText="备 注" >
<HeaderStyle CssClass="gdvtop" />
</asp:BoundField>
<asp:CommandField HeaderText="选择" ShowSelectButton="True" >
<HeaderStyle CssClass="gdvtop" />
</asp:CommandField>
<asp:CommandField HeaderText="编辑" ShowEditButton="True" >
<HeaderStyle CssClass="gdvtop" />
</asp:CommandField>
<asp:CommandField HeaderText="删除" ShowDeleteButton="True" >
<HeaderStyle CssClass="gdvtop" />
</asp:CommandField>
</Columns>
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
</asp:GridView>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bind();
}
gdv.Attributes.Add("bordercolor", "B8B3B3");
}
private void bind()
{
SupplierBLL subll = new SupplierBLL();
DataTable dt = subll.GetAllSupplier();
gdv.DataSource = dt;
gdv.DataKeyNames = new string[] { "su_ID" };
gdv.DataBind();
}
protected void gdv_RowEditing(object sender, GridViewEditEventArgs e)
{
gdv.EditIndex = e.NewEditIndex;
}
protected void gdv_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
SupplierBLL subll = new SupplierBLL();
int suID = int.Parse(gdv.DataKeys[e.RowIndex].Value.ToString());
int res = subll.DelSupplier(suID);
if (res <= 0)
{
Response.Write("<script>alert('此供应商记录被其它信息引用,无法删除。')</script>");
}
bind();
}
protected void gdv_DataBound(object sender, EventArgs e)
{
for (int i = 0; i < gdv.Rows.Count; i++)
{
gdv.Rows[i].Cells[8].Attributes.Add("onclick", "return confirm('确定删除吗?')");
}
}
protected void gdv_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
SupplierInfo suinfo = new SupplierInfo(int.Parse(gdv.DataKeys[e.RowIndex].Value.ToString()), ((TextBox)(gdv.Rows[e.RowIndex].Cells[0].Controls[0])).Text.ToString().Trim(), ((TextBox)(gdv.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim(), ((TextBox)(gdv.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim(), ((TextBox)(gdv.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim(), ((TextBox)(gdv.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim(), ((TextBox)(gdv.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim());
SupplierBLL subll = new SupplierBLL();
bind();
}
protected void gdv_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gdv.EditIndex = -1;
}
<asp:GridView ID="gvBOM" runat="server" ShowHeader="false" Style="margin: 0px; padding: 0px;
background-color: #DAE7EF" Width="100%" AutoGenerateColumns="False" DataKeyNames="BillOfMaterialsID"
OnRowEditing="gvBOM_RowEditing" OnRowUpdating="gvBOM_RowUpdating" OnRowCancelingEdit="gvBOM_RowCancelingEdit"
OnRowDeleting="gvBOM_RowDeleting" OnRowCreated="gvBOM_RowCreated">
<Columns>
<asp:TemplateField HeaderText="原料名称">
<ItemTemplate>
<%# Eval("ProductCat")%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="120px" />
<HeaderStyle HorizontalAlign="Center" Font-Bold="false" Width="120px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="原料规格">
<ItemTemplate>
<%# Eval("YarnCount")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TBBOMYarnCount" runat="server" Text='<%# Eval("YarnCount")%>' CssClass="TBinput"
Width="100px"></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Right" Width="100px" />
<HeaderStyle HorizontalAlign="Center" Font-Bold="false" Width="50px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="成分比例">
<ItemTemplate>
<%# Eval("ScaleModel")%>%
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TBScaleModel" runat="server" Text='<%# Eval("ScaleModel")%>' CssClass="TBinput"
Width="40px"></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Right" Width="50px" />
<HeaderStyle HorizontalAlign="Center" Font-Bold="false" Width="50px" />
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" DeleteText="<div id="de" onclick="JavaScript:return confirm('确定删除吗?')">删除</div> " />
</Columns>
<EditRowStyle BackColor="#DAE7EF" />
<PagerStyle BorderStyle="Outset" />
</asp:GridView>
protected void gvBOM_RowEditing(object sender, GridViewEditEventArgs e)
{
ProductCat myProductCat = new ProductCat();
gvBOM.EditIndex = e.NewEditIndex;
int OrdersDetailID=Int32.Parse(HidDetailID.Value);
Orders myOrders = new Orders();
DataSet dsBOM = myOrders.Get_OrdersDetailBOMByOrdersDetaiID_List(OrdersDetailID);
gvBOM.DataSource = dsBOM.Tables[0];
gvBOM.DataBind();
}
protected void gvBOM_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//此处执行更新操作
gvBOM_DataBind(CurOrdersDetailID); //重新帮定GridView
gvBOM.EditIndex = -1;
}
protected void gvBOM_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvBOM.EditIndex = -1;
int OrdersDetailID = Int32.Parse(HidDetailID.Value);
gvBOM_DataBind(OrdersDetailID);//重新帮定GridView
}
protected void gvBOM_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
//此处执行删除操作
gvBOM_DataBind(CurOrdersDetailID);//重新帮定
}
protected void gdv_RowEditing(object sender, GridViewEditEventArgs e)
{
gdv.EditIndex = e.NewEditIndex;
}