I am trying to call the DataBind() method on a formview control from a insert button's method and I'm getting the error "The name 'StatePaymentsCalculatedFields' does not exist in the current context' ". Here is my code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Data;
public partial class Users_EDSInvoice : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnInsert_Click(object sender, EventArgs e)
{
DropDownList acct = gvStatePayments.FooterRow.FindControl("ddlAcct") as DropDownList;
TextBox pmtdate = gvStatePayments.FooterRow.FindControl("dtPmtDate") as TextBox;
TextBox scr = gvStatePayments.FooterRow.FindControl("txtSCR") as TextBox;
DropDownList extcat = gvStatePayments.FooterRow.FindControl("ddlExtCat") as DropDownList;
TextBox pmt = gvStatePayments.FooterRow.FindControl("txtPmt") as TextBox;
TextBox notes = gvStatePayments.FooterRow.FindControl("txtNotes") as TextBox;
sdsStatePayments.InsertParameters["for_ID"].DefaultValue = InvoiceDropDown.SelectedValue;
sdsStatePayments.InsertParameters["Acct"].DefaultValue = acct.Text;
sdsStatePayments.InsertParameters["Pmt_Date"].DefaultValue = pmtdate.Text;
sdsStatePayments.InsertParameters["SCR#"].DefaultValue = scr.Text;
sdsStatePayments.InsertParameters["ExtCatID"].DefaultValue = extcat.SelectedValue;
sdsStatePayments.InsertParameters["Pmt"].DefaultValue = pmt.Text;
sdsStatePayments.InsertParameters["Notes"].DefaultValue = notes.Text;
sdsStatePayments.Insert();
StatePaymentsDetails.DataBind();
StatePaymentsCalculatedFields.DataBind();
}
protected void btnEmptyInsert_Click(object sender, EventArgs e)
{
DropDownList acct = gvStatePayments.Controls[0].Controls[0].FindControl("ddlAcct") as DropDownList;
TextBox pmtdate = gvStatePayments.Controls[0].Controls[0].FindControl("dtPmtDateEmpty") as TextBox;
TextBox scr = gvStatePayments.Controls[0].Controls[0].FindControl("txtSCR") as TextBox;
DropDownList extcat = gvStatePayments.Controls[0].Controls[0].FindControl("ddlExtCat") as DropDownList;
TextBox pmt = gvStatePayments.Controls[0].Controls[0].FindControl("txtPmt") as TextBox;
TextBox notes = gvStatePayments.Controls[0].Controls[0].FindControl("txtNotes") as TextBox;
sdsStatePayments.InsertParameters["for_ID"].DefaultValue = InvoiceDropDown.SelectedValue;
sdsStatePayments.InsertParameters["Acct"].DefaultValue = acct.Text;
sdsStatePayments.InsertParameters["Pmt_Date"].DefaultValue = pmtdate.Text;
sdsStatePayments.InsertParameters["SCR#"].DefaultValue = scr.Text;
sdsStatePayments.InsertParameters["ExtCatID"].DefaultValue = extcat.SelectedValue;
sdsStatePayments.InsertParameters["Pmt"].DefaultValue = pmt.Text;
sdsStatePayments.InsertParameters["Notes"].DefaultValue = notes.Text;
sdsStatePayments.Insert();
StatePaymentsDetails.DataBind();
StatePaymentsCalculatedFields.DataBind();
}
protected void DetailsView_ItemDeleted(object sender, FormViewDeletedEventArgs e)
{
InvoiceDropDown.Items.Clear();
InvoiceDropDown.DataBind();
Response.Redirect("EDSInvoice.aspx");
}
protected void DetailsView_ItemInserted(object sender, FormViewInsertedEventArgs e)
{
Response.Redirect("EDSInvoice.aspx");
}
protected void gvStatePayments_deleted(object sender, GridViewDeletedEventArgs e)
{
StatePaymentsDetails.DataBind();
StatePaymentsCalculatedFields.DataBind();
}
protected void gvStatePayments_updated(object sender, GridViewUpdatedEventArgs e)
{
StatePaymentsDetails.DataBind();
StatePaymentsCalculatedFields.DataBind();
}
}
I don't understand why the StatePaymentsDetails.DataBind() call works but the StatePaymentsCalculatedFields.DataBind() call does not exist!
They are both on the same page, the first one is a databound Gridview and the latter is a databound FormView.
Any help in understanding why this is generating and error and how to make this call successfully is greatly appreciated.
Hi
where is datasource ?
did you ever assigning datasource ?
沒有留言:
張貼留言