C
chh.552
Guest
The operands '-' and '/' are not operands of type 'string' and 'int'. How do I solve an error?
My value is in string format.
private void MoveRow(int sourceRow, int targetRow)
{
if (sourceRow == targetRow)
return;
GridView view = grvProgramStdInfo;
DataRow row0 = null;
DataRow row1 = null;
DataRow row2 = null;
string val1 = "";
string val2 = "";
if (targetRow == sourceRow + 1)
{
row1 = view.GetDataRow(sourceRow);
row2 = view.GetDataRow(targetRow);
val1 = (string)row1[OrderFieldName];
val2 = (string)row2[OrderFieldName];
row1[OrderFieldName] = val2;
row2[OrderFieldName] = val1;
view.FocusedRowHandle = sourceRow + 1;
return;
}
if (sourceRow == targetRow + 1)
{
row1 = view.GetDataRow(sourceRow);
row2 = view.GetDataRow(targetRow);
val1 = (string)row1[OrderFieldName];
val2 = (string)row2[OrderFieldName];
row1[OrderFieldName] = val2;
row2[OrderFieldName] = val1;
view.FocusedRowHandle = sourceRow - 1;
return;
}
row0 = view.GetDataRow(targetRow - 1);
row1 = view.GetDataRow(targetRow);
row2 = view.GetDataRow(targetRow + 1);
DataRow dragRow = view.GetDataRow(sourceRow);
val1 = (string)row1[OrderFieldName];
if (row2 == null)
dragRow[OrderFieldName] = val1 + 1;
else
{
val2 = (string)row2[OrderFieldName];
if (row0 == null)
dragRow[OrderFieldName] = val1 - 1;
else
dragRow[OrderFieldName] = (val1 + val2) / 2;
}
}
Continue reading...
My value is in string format.
private void MoveRow(int sourceRow, int targetRow)
{
if (sourceRow == targetRow)
return;
GridView view = grvProgramStdInfo;
DataRow row0 = null;
DataRow row1 = null;
DataRow row2 = null;
string val1 = "";
string val2 = "";
if (targetRow == sourceRow + 1)
{
row1 = view.GetDataRow(sourceRow);
row2 = view.GetDataRow(targetRow);
val1 = (string)row1[OrderFieldName];
val2 = (string)row2[OrderFieldName];
row1[OrderFieldName] = val2;
row2[OrderFieldName] = val1;
view.FocusedRowHandle = sourceRow + 1;
return;
}
if (sourceRow == targetRow + 1)
{
row1 = view.GetDataRow(sourceRow);
row2 = view.GetDataRow(targetRow);
val1 = (string)row1[OrderFieldName];
val2 = (string)row2[OrderFieldName];
row1[OrderFieldName] = val2;
row2[OrderFieldName] = val1;
view.FocusedRowHandle = sourceRow - 1;
return;
}
row0 = view.GetDataRow(targetRow - 1);
row1 = view.GetDataRow(targetRow);
row2 = view.GetDataRow(targetRow + 1);
DataRow dragRow = view.GetDataRow(sourceRow);
val1 = (string)row1[OrderFieldName];
if (row2 == null)
dragRow[OrderFieldName] = val1 + 1;
else
{
val2 = (string)row2[OrderFieldName];
if (row0 == null)
dragRow[OrderFieldName] = val1 - 1;
else
dragRow[OrderFieldName] = (val1 + val2) / 2;
}
}
Continue reading...