62,271
社区成员
发帖
与我相关
我的任务
分享<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridViewFoodManage" runat="server"
AutoGenerateColumns="False" DataKeyNames="FoodID"
>
<Columns>
<asp:TemplateField HeaderText="是否发布">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server"
/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FoodName" HeaderText="菜品名称" />
<asp:BoundField DataField="SupplierID" HeaderText="商家ID" />
<asp:BoundField DataField="Price" HeaderText="价格" />
<asp:BoundField DataField="FoodTypeID" HeaderText="菜品种类" />
<asp:BoundField DataField="Nice" HeaderText="好评数" />
<asp:BoundField DataField="Bad" HeaderText="差评数" />
<asp:BoundField DataField="IsPublished" HeaderText="是否发布" />
<asp:BoundField DataField="IsRecommended" HeaderText="是否推荐" />
</Columns>
<EmptyDataTemplate>
抱歉,没有数据!
</EmptyDataTemplate>
</asp:GridView>
<br />
<asp:Button ID="ButtonApply" runat="server" onclick="ButtonApply_Click"
Text="提交" />
</div>
</form>
</body>
</html>
public partial class FoodAdmin_FoodAudit : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionstr = ConfigurationManager.ConnectionStrings["Ncepu.iDeal.Wmw.Foods.Data.ConnectionString"].ToString();
SqlFoodProvider sfp = new SqlFoodProvider(connectionstr, false, "Ncepu.iDeal.Wmw.Foods.Data.SqlClient");
TList<Food> tfTemp = sfp.GetAll();
TList<Food> tf = new TList<Food>();
for (int i = 0; i < tfTemp.Count; i++)
{
if (tfTemp[i].IsPublished == 0)
{
tf.Add(tfTemp[i]);
}
else
{
continue;
}
}
GridViewFoodManage.DataSource = tf;
GridViewFoodManage.DataBind();
}
protected void ButtonApply_Click(object sender, EventArgs e)
{
for (int i = 0; i < GridViewFoodManage . Rows.Count; i++)
{
GridViewRow row = GridViewFoodManage.Rows[i];
bool isChecked = ((CheckBox)row.FindControl("CheckBox1")).Checked;
int BoxID = Convert.ToInt32(GridViewFoodManage.DataKeys[GridViewFoodManage.Rows[i].DataItemIndex].Value);
if (isChecked)
{
Response.Write("ok");
}
}
}