"Edit Update Cancel"コマンドフィールドを持つgridviewがあります。編集をクリックすると、特定の行のすべての列が編集可能になり、更新をクリックすると、新しい値に基づいて表が更新されます。 次に、Gridviewは更新されたデータテーブルにバインドされます。しかし、「Update Cancel」ボタンはまだ のままです。行一度更新後にノーマルモードで行を作成する必要があります
、ボタンを可能にしたということですので、どのように「編集」に変更する必要があり、「更新がキャンセル」、更新されています。アドバンス
で
おかげこれは、更新されたデータを更新して表示するためのコード
protected void StaticNoticeGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
//Gets the updated value from GridView
string id = StaticNoticeGridView.Rows[e.RowIndex].Cells[0].Text;
string updatedItem = e.NewValues[0].ToString();
string updatedURL = e.NewValues[1].ToString();
//Updated the Database
StaticNoticeController staticNoticeController = new StaticNoticeController();
int rocordsAffected = staticNoticeController.UpdateStaticNoticeData(updatedItem, updatedURL, id);
//Gets the updated datatable and binds the Gridview again
if (rocordsAffected == 1)
{
this.StaticNoticeGridView.DataSource = null;
this.StaticNoticeGridView.DataSource = staticNoticeController.GetStaticNoticeData();
this.StaticNoticeGridView.DataBind();
}
}
catch(SystemException ex)
{
//ToDo: Log the Exception
}
}
で
this.StaticNoticeGridView.DataBind();
前にコードをご提示ください更新のクリックイベントハンドラに使用します。 – Hogan@Hogan Thanks ..コードが質問に追加されました。 – Ananth