Exemple #1
0
    //update data

    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string    id = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
        Hashtable ht = new Hashtable();

        string[] arr1 = new string[] { "title", "time0", "kind" };
        for (int i = 0; i < arr1.Length - 1; i++)
        {
            ht.Add(arr1[i], Util.GetControlValue(this.GridView1.Rows[e.RowIndex].Cells[i].Controls[0]));
        }

        ht.Add(arr1[2], ((DropDownList)this.GridView1.Rows[e.RowIndex].Cells[2].FindControl("DropDownList1")).SelectedValue);
        if (ht["title"].ToString().Trim() == "")
        {
            Util.alert(this.Page, "错误提示:标题不能为空");
        }
        else
        {
            ZX_InfoBU info1  = new ZX_InfoBU();
            bool      result = info1.UpdateData(id, ht);
            info1.Close();
            if (result)
            {
                this.GridView1.EditIndex = -1;
                this.BindData(info1);
                Util.alert(this.Page, "修改成功!");
            }
            else
            {
                Util.alert(this.Page, "修改失败!");
            }
        }
    }