Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3555
RefreshRow.ReloadData Issue
posted
Ok, the problem is I am trying to call the following method,
RefreshRow.ReloadData

I am working with ADo disconnected data. So to prevent to grid from
redrawing back to its original state I merge the datatable that is binded to
the grid with the new updated data table, and then I call the above method.
This has worked before, but for some reason it is not working right away.

Now I did step through my code, and the merge works fine, as I printed both
the current binded table and the new table and the final merge table.
However, it seems the actual RefreshRow.ReloadData doesn't happen until I do
an additional aftercellupdate event. I have spent hours trying to figure
this out.

Code is below and I made a comment in bold red where I think the problem is.

~Patrick






--------------------------------------------------------------------------------

From: Ho Phu, Johnny
Sent: Friday, September 26, 2008 1:57 PM
To: Ryan, Patrick
Subject:



private DataTable PricingListLoader2()

{

DataTable dt = new DataTable();

ReviewerPricingDrugSelectByVersionID pricingSelect2 = new
ReviewerPricingDrugSelectByVersionID();

try

{

pricingSelect2.Invoke();

//Add calculated columns to the dataset

dt = pricingSelect2.ResultSet.Tables[0];

dt.PrimaryKey = new DataColumn[ { dt.Columns[0] };

dt.Columns.Add(new DataColumn("PricePerUnit",
Type.GetType("System.Decimal"), "[ExManSales] / [UnitSales]"));

dt.Columns.Add(new DataColumn("PricePerDoseUnit",
Type.GetType("System.Decimal"), "[PricePerUnit]/
[DoseUnitsPerReportedPrice]"));

dt.Columns.Add(new DataColumn("PricePerAdminDay",
Type.GetType("System.Decimal")));

dt.Columns["PricePerAdminDay"].ReadOnly = false;

dt.Columns.Add(new DataColumn("PricePerTreatedDays",
Type.GetType("System.Decimal")));

dt.Columns["PricePerTreatedDays"].ReadOnly = false;



for (int i = 0; i

{

decimal doseUnitsPerAdminDay =
Convert.ToDecimal(dt.Rows[i]["DoseUnitsPerAdminDay"].ToString());

decimal MgPerAdminDay =
Convert.ToDecimal(dt.Rows[i]["MgPerAdminDay"].ToString());

int MgPerDoseUnit =
int.Parse(dt.Rows[i]["MgPerDoseUnit"].ToString());

decimal compareZero = 0.0M;

decimal pricePerDoseUnits =
Convert.ToDecimal(dt.Rows[i]["PricePerDoseUnit"].ToString());

if (MgPerDoseUnit > 0 && MgPerAdminDay > compareZero)

{

dt.Rows[i]["PricePerAdminDay"] = pricePerDoseUnits /
(MgPerAdminDay / MgPerDoseUnit);

}

else

{

if (doseUnitsPerAdminDay > compareZero)

{

dt.Rows[i]["PricePerAdminDay"] =
pricePerDoseUnits / doseUnitsPerAdminDay;

}

else

{

dt.Rows[i]["PricePerAdminDay"] = compareZero;

}

}



}



//Fill PricePerTreatedDays column



for (int j = 0; j

{

decimal dayDurationOfDose =
Convert.ToDecimal(dt.Rows[j]["DaysDurationOfDose"].ToString());



if (dayDurationOfDose > 0.0M)

{

decimal priceAdminDay =
Convert.ToDecimal(dt.Rows[j]["PricePerAdminDay"].ToString());

dt.Rows[j]["PricePerTreatedDays"] = priceAdminDay /
dayDurationOfDose;

}

else

{

dt.Rows[j]["PricePerTreatedDays"] = 0.0M;

}

}



}

catch (Exception ex)

{

EventLogger el = new EventLogger();

bool isLogged;

dt = null;

isLogged = el.WriteToEventLog(ex.Message,
"MarketForecasterApp", EventLogEntryType.Error, "MarketForecaterApp");

if (isLogged == true)

{

MessageBox.Show("Event logged.");

}

}

return dt;



}













private void grdPricingList_AfterCellUpdate(object sender, CellEventArgs e)

{

EditorPricingDrugUpdate pricingDrugUpdate = new
EditorPricingDrugUpdate();

PricingDrug pricingDrug = new PricingDrug();

string myString =
grdPricingList.ActiveRow.Cells["PricingDrugID"].Value.ToString();



pricingDrug.PricingDrugID =
int.Parse(grdPricingList.ActiveRow.Cells["PricingDrugID"].Value.ToString());

pricingDrug.Weights =
Convert.ToDecimal(grdPricingList.ActiveRow.Cells["Weights"].Value.ToString());

pricingDrug.DoseUnitsPerReportedPrice =
int.Parse(grdPricingList.ActiveRow.Cells["DoseUnitsPerReportedPrice"].Value.ToString());

pricingDrug.DoseUnitsPerAdminDay =
Convert.ToDecimal(grdPricingList.ActiveRow.Cells["DoseUnitsPerAdminDay"].Value.ToString());

pricingDrug.MgPerDoseUnit =
int.Parse(grdPricingList.ActiveRow.Cells["MgPerDoseUnit"].Value.ToString());

pricingDrug.MgPerAdminDay =
Convert.ToDecimal(grdPricingList.ActiveRow.Cells["MgPerAdminDay"].Value.ToString());

pricingDrug.DaysDurationOfDose =
Convert.ToDecimal(grdPricingList.ActiveRow.Cells["DaysDurationOfDose"].Value.ToString());



pricingDrugUpdate.PricingDrug = pricingDrug;



try

{

pricingDrugUpdate.Invoke();



tblMerge = PricingListLoader2();

tblMerge.PrimaryKey = new DataColumn[ {
tblMerge.Columns["PricingDrugID"] };





// Merge new data into the modified data

tblPricingDrug.Merge(tblMerge, false);



this.grdPricingList.Rows.Refresh(Infragistics.Win.UltraWinGrid.RefreshRow.ReloadData);

THIS DOESN"T WORK UNTIL I DO ANOTHER AFTERCELLUPDATE
EVENT, IT SEEMS THE RELOAD IS ALWAYS ONE STEP BEHIND)





//grdPricingList.Rows.Refresh(RefreshRow.ReloadData);

//grdPricingList.Refresh();





}

catch (Exception ex)

{

MessageBox.Show("Did Not Update To Database: " +
ex.Message);

}

}
Parents
No Data
Reply Children
No Data