GridView and OCDS

Aug 5, 2008 at 7:22 AM
Hi,
I'm trying to insert record thru the footer of the grid views, belows is my code.

 

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e){
    
if (e.CommandName.CompareTo("Insert") == 0)
    {
        //How do i reset the OCDS to take the value from the footer
    
}
}

 protected
void CustomerDataSource_Inserting(object sender, Microsoft.Practices.Web.UI.WebControls.ObjectContainerDataSourceInsertingEventArgs e){
TextBox NewCustomerID = (TextBox)GridView1.FooterRow.FindControl("NewCustomerID");
TextBox NewFirstName = (TextBox)GridView1.FooterRow.FindControl("NewFirstName");
TextBox NewLastName = (TextBox)GridView1.FooterRow.FindControl("LastName");
TextBox NewEmailAddress = (TextBox)GridView1.FooterRow.FindControl("NewEmailAddress");
e.NewValues[
"CustomerID"] = NewCustomerID;
e.NewValues[
"FirstName"] = NewFirstName;
e.NewValues[
"LastName"] = NewLastName;
e.NewValues[
"EmailAddress"] = NewEmailAddress;
}
protected void CustomerDataSource_Inserted(object sender, Microsoft.Practices.Web.UI.WebControls.ObjectContainerDataSourceStatusEventArgs e)
{
    _presenter.OnCustomerAdded((
Customer)e.Instance);
}

Thanks in advance.

 

Aug 5, 2008 at 9:15 PM

Hi,

 

Please provide more relevant information on this issue, to understand the context a little better.

Nevertheless, I see that you are setting the textboxes to the NewValues dictionary and not the content of the textbox (getting the value of the textbox from the Text property).

 

Also, the ObjectContainerDataSource QuickStart may be a good sample, as it handles insertion too.

 

Let me know if this helps,

 

Ignacio Baumann Fonay

http://blogs.southworks.net/ibaumann/