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
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 the grid from
resetting back to its original state/layout I merge the datatable that is
binded to
the grid with a new updated data table, and then I call the
RefreshRow.ReloadData method of the grid.
This has worked before, but for some reason it is not working correctly this
time.


I did step through my code, and the datatable 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, as if there is a delay or something. I
have spent hours trying to figure
this out. I have implemented the same architect on another project without
any problems.

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

~Patrick






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);

}

}
  • 469350
    Offline posted

    Hi,

    It's really hard to tell anything from code snippets like this. Can you duplicate the problem in a small sample project? If so, you should Submit an incident to Infragistics Developer Support and they should be able to tell you why it's not working. 

    Your mention of AfterCellUpdate is interesting. Are you calling Refresh while there is a cell in the middle of an update? If that's the case, then that might be the problem. To test that theory, you might try calling PerfromAction(ExitEditMode) on the grid before you call Refresh and see if that makes any difference.