Reputation: 432
i have a DetailsView bound to a Datatable
I managed to use my own Edit, Update, Cancel buttons
the problem I'm facing is I can't get the value of DetailsView cells when updating
here is my code to get values in EditMode
protected void BP_Info_View_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
if (BP_Info_View.CurrentMode == DetailsViewMode.Edit)
{
//get the value of fields from detailsView
string cardname = BP_Info_View.Rows[0].Cells[1].Text.ToString();
string address = BP_Info_View.Rows[1].Cells[1].Text.ToString();
string zipcode = BP_Info_View.Rows[2].Cells[1].Text.ToString();
string mailaddress = BP_Info_View.Rows[3].Cells[1].Text.ToString();
string mailzipcode = BP_Info_View.Rows[4].Cells[1].Text.ToString();
string phone1 = BP_Info_View.Rows[5].Cells[1].Text.ToString();
string phone2 = BP_Info_View.Rows[6].Cells[1].Text.ToString();
string cell = BP_Info_View.Rows[7].Cells[1].Text.ToString();
string fax = BP_Info_View.Rows[8].Cells[1].Text.ToString();
string cntprsn = BP_Info_View.Rows[9].Cells[1].Text.ToString();
string city = BP_Info_View.Rows[10].Cells[1].Text.ToString();
//update here
}
}
update works perfect If I assign other data to my variables.
what is missing of my code to retrieve values from DetailsView in editMode?
Thank You!
Upvotes: 0
Views: 928
Reputation: 432
TextBox tx = BP_Info_View.Rows[7].Cells[1].Controls[0] as TextBox;
should use TextBox, in EditMode it's textbox not string!
Upvotes: 0