private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
Info MyInfo = new Info();
ArrayList a = new ArrayList();
a.Add((int)DataGrid1.DataKeys[e.Item.ItemIndex]);
a.Add(((DropDownList)e.Item.FindControl("dg_ddlBigSort")).SelectedItem.Value);
a.Add(((DropDownList)e.Item.FindControl("dg_ddlSmallSort")).SelectedItem.Value); if(MyInfo.UpdateBigSortSmallSortWhereID(a) == "1")
{
Response.Write("<script>alert('更新成功!')</script>");
DataGrid1.EditItemIndex = -1;
dgInfoAllBind();
}
else
{
Response.Write("<script>alert('更新失败!')</script>");
}
}
{
Info MyInfo = new Info();
ArrayList a = new ArrayList();
a.Add((int)DataGrid1.DataKeys[e.Item.ItemIndex]);
a.Add(((DropDownList)e.Item.FindControl("dg_ddlBigSort")).SelectedItem.Value);
a.Add(((DropDownList)e.Item.FindControl("dg_ddlSmallSort")).SelectedItem.Value); if(MyInfo.UpdateBigSortSmallSortWhereID(a) == "1")
{
Response.Write("<script>alert('更新成功!')</script>");
DataGrid1.EditItemIndex = -1;
dgInfoAllBind();
}
else
{
Response.Write("<script>alert('更新失败!')</script>");
}
}
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
Info MyInfo = new Info();
ArrayList a = new ArrayList();
a.Add((int)DataGrid1.DataKeys[e.Item.ItemIndex]);
a.Add(((DropDownList)e.Item.FindControl("dg_ddlBigSort")).SelectedItem.Value);
a.Add(((DropDownList)e.Item.FindControl("dg_ddlSmallSort")).SelectedItem.Value); if(MyInfo.UpdateBigSortSmallSortWhereID(a) == "1")
{
Response.Write("<script>alert('更新成功!')</script>");
DataGrid1.EditItemIndex = -1;
dgInfoAllBind();
}
else
{
Response.Write("<script>alert('更新失败!')</script>");
}
}
=====================================>
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.EditItem)
{
Sort MySort = new Sort();
((DropDownList)e.Item.FindControl("dg_ddlBigSort")).DataSource = MySort.ddlBigSortBind();
((DropDownList)e.Item.FindControl("dg_ddlBigSort")).DataTextField = "BigSort";
((DropDownList)e.Item.FindControl("dg_ddlBigSort")).DataValueField = "BigSort";
((DropDownList)e.Item.FindControl("dg_ddlBigSort")).DataBind(); ((DropDownList)e.Item.FindControl("dg_ddlSmallSort")).DataSource = MySort.dgSmallSortBind();
((DropDownList)e.Item.FindControl("dg_ddlSmallSort")).DataTextField = "SmallSort";
((DropDownList)e.Item.FindControl("dg_ddlSmallSort")).DataValueField = "SmallSort";
((DropDownList)e.Item.FindControl("dg_ddlSmallSort")).DataBind();
}
}
{
conn = new SqlConnection(ConfigurationSettings.AppSettings["dsn"]);
da = new SqlDataAdapter();
da.UpdateCommand = new SqlCommand("Sp_Kflash_Info_UpdateBigSortSmallSortWhereID",conn);
da.UpdateCommand.CommandType = CommandType.StoredProcedure; da.UpdateCommand.Parameters.Add("@ID",SqlDbType.Int).Value = a[0];
da.UpdateCommand.Parameters.Add("@BigSort",SqlDbType.VarChar,50).Value = a[1];
da.UpdateCommand.Parameters.Add("@SmallSort",SqlDbType.VarChar,50).Value = a[2]; conn.Open();
try
{
da.UpdateCommand.ExecuteNonQuery();
}
catch(Exception e)
{
Console.Write(e.Message);
}
finally
{
conn.Dispose();
conn.Close();
} return "1";
}
UP,高手帮忙看看啊
我就是因为这个没有设置,所以在datalist中的东西总是不能更新数据库。