This is the scenario:
I have a web page with a ListView lv_create_claim which contains a nested ListView lv_fees which contain textboxes.
On update_button click I need to validate all values in textboxes on database. Procedure will return status and validation errors. If there are any errors I need to repopulate lv_fees textboxes with entered values. So I need to keep all entered data in session. To accomplish this I update session DataTable iterating through all textboxes in all nested lv_fees.
Here is the question. Is there any better and more efficient way to update session DataTable with values I get from ListView.
DataTable dt = HttpContext.Current.Session[ "PopulationData" ] as DataTable;
int i = 0;
foreach( ListViewItem item in lv_create_claim.Items )
{
ListView fees = item.FindControl( "lv_fees" ) as ListView;
DataRow row;
foreach( ListViewDataItem x in fees.Items )
{
row = dt.Rows[ i ];
row.BeginEdit();
row[ "claim_amt" ] = PFFormat.GetCurrency(( x.FindControl( "txb_cliam" ) as TextBox ).Text);
row[ "start_date" ] = ( x.FindControl( "txb_from_date" ) as TextBox ).Text;
row[ "end_date" ] = ( x.FindControl( "txb_from_date" ) as TextBox ).Text;
row.EndEdit();
i++;
}
}
The question does not make much sense. Close it.