Monday, March 26, 2012

UpdatePanel (Ajax) with DetailView

Hi All:

I have an UpdatePanel(Ajax) and inside one DetailView. When I try to insert a new record in the DetailView the new values are "" (null) . I don't know what I am doing wrong. He re is part of my code for get the values from the DetailView

protected

void DetailsView1_ItemInserting(object sender,DetailsViewInsertEventArgs e)

{

TextBox txtRow_MasterCustId = ((TextBox)DetailsCustomerMaster2.FindControl("TextBox0")); // The values are ""TextBox txtMaster_CustomerId = ((TextBox)DetailsCustomerMaster2.FindControl("TextBox1")); // The values are ""

ObjectDatacustomerMasterDetails.InsertParameters[1].DefaultValue = txtMaster_CustomerId.Text;

ObjectDatacustomerMasterDetails.InsertParameters[2].DefaultValue = txtCustomer_Name.Text;

}

I appreciate any help

thanks

Can you please elaborate on the problem. What I understand is briefly as

Problem Identified As: That when you insert a null value, it does not get inserted into the database.

Solution: Check your database fields first. If nulls are not accepted, then this problem could possibly arise.

Problem Identified As: Even if you insert data, only nulls are inserted.

Solution: This could be possibly because of the queries that are associated with the detailsview. Happens when you've not specified the fields properly in the queries.

Please reply if what I've understood was right and if they solved your problem. Else elaborate more on the problem to clarify what the problem actually is. It is not clear with your message.

Enzoi!!!


The problem is that when I click the Insert button in the DetailView ( the DetailView is in Insert Mode), the values that holds the textboxes are empty. The user typed some values to each textbox in the Detailview for Insert a new record. I try to get the new values inserted by the user before the inserting but there are not values.

protected

void DetailsView1_ItemInserting(object sender,DetailsViewInsertEventArgs e)

{

TextBox txtRow_MasterCustId = ((TextBox)DetailsCustomerMaster2.FindControl("TextBox0")); //The textbox is empty but the user inserted some textTextBox txtMaster_CustomerId = ((TextBox)DetailsCustomerMaster2.FindControl("TextBox1"));TextBox txtCustomer_Name = ((TextBox)DetailsCustomerMaster2.FindControl("TextBox2"));

ObjectDatacustomerMasterDetails.InsertParameters[1].DefaultValue = txtMaster_CustomerId.Text; //The textbox is empty but the user inserted some text so the parameter are empty

ObjectDatacustomerMasterDetails.InsertParameters[2].DefaultValue = txtCustomer_Name.Text;

ObjectDatacustomerMasterDetails.InsertParameters[3].DefaultValue = txtAddress.Text;

}

If I put the DetailView outside of the update panel , it works. I can get the new values and the parameters are fine in the InsertParameter

but if it is inside of the update panel is not working. I can't get the new values and the parameters are empty. Why the differences ?

Thank you for any help.


Have you found any solution?

I'm having the same problem except from the fact that I'm not using any Ajax. My program was working fine, but after integrating with some design (pics and CSS, ...etc) the TextBoxes are always empty when submitting a page, even if the user writes things in there. The textboxes are found in the code-behind page (not null, but do exist) However their .Text value is always an empty string no matter what the user writes in them.


No I don't have a solution ?

I am waiting that somebody can help me.

No comments:

Post a Comment