FormView

出自ProgWiki

跳轉到: 導航, 搜尋

FormViewSystem.Web.UI.WebControls.FormView


目錄

FAQ

如何在DataBinding或DataBound事件中取得資料

protected void FormView1_DataBound(object sender, EventArgs e)
{
 
         DataRowView RowView = FormView1.DataItem as DataRowView;
         if (RowView != null)
         {
                  this.ID.Value = RowView["ID"].ToString();
         }
}

如何自SqlDataSource取回Insert後的傳回值

protected void SqlDataSource1_Inserted(object sender, SqlDataSourceStatusEventArgs e)
{
        this.ID.Value = e.Command.Parameters["@ID"].Value.ToString();
}

關於使用OnItemInserted或OnItemUpdated事件去檢查資料是否成功寫入資料庫

關於Insert或Edit模式下的取消按鈕

protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
{
    if (e.CommandName == "Cancel")
    { 
       if (this.FormView1.CurrentMode == FormViewMode.Insert)
       {
            //Insert模式下的取消按鈕
       }
       else if (this.FormView1.CurrentMode == FormViewMode.Edit)
       {
            //Edit模式下的取消按鈕
       }
    }
}
個人工具
名字空間
變換
動作
導航
分類
其他
技術類News或部落格
工具箱