I am working on a project in which i read multiple field from an excel file and save them in db.How to show multiple errors messages on a page if user enters wrong value. Aspose.cells is used for reading data.My code is
public List<Data> ImportFromExcel(Stream bytes, out bool isFine)
{
isFine = true;
DateTime DOJ;
List<Data> list = new List<Data>();
DataTable dt = new DataTable();
Workbook workBook = new Workbook();
workBook.Open(bytes);
Worksheet workSheet = workBook.Worksheets[0];
try
{
dt = workSheet.Cells.ExportDataTable(0, 0, workSheet.Cells.MaxRow + 1, workSheet.Cells.MaxColumn + 1, true);
}
catch (Exception ex)
{
isFine = false;
ShowMessage("Your file has some invalid formats of data. Please review it and try again.", MessageType.Error, true);
return null;
}
try
{
int i = 1;
foreach (DataRow reader in dt.Rows)
{
if (reader["LetterId"].ToString().Length > 75)
{
isFine = false;
ShowMessage("In Row Number " + i + " Letter Id cannot exceed 75 characters.", MessageType.Error, true);
return null;
}
if (reader["Subject"].ToString().Length > 75)
{
isFine = false;
ShowMessage("In Row Number " + i + " Subject cannot exceed 75 characters.", MessageType.Error, true);
return null;
}
.
.
.
Show message method shows only single error message.
You could create an empty list of strings, and then each time you encounter an error just add it to the list. Then once you have all the errors in your list, you can just do this:
string allErrors = string.Empty;
foreach (string err in errorList)
{
allErrors += err + "<br />";
}
if (allErrors != string.Empty)
{
ShowMessage(allErrors);
}
Related
I have a method which create an excel file (.xlsx) from a list of strings using DocumentFormat.OpenXml. The created file needs to be repaired when I try to open it with Excel 2016. When I click "Yes" Excel shows my file correctly.
Does anyone have any suggestions? Thanks in advance.
Here's my code:
private byte[] ExportDataXlsx(System.Data.Common.DbDataReader reader, string[] fields, string[] headers, string Culture) {
System.IO.MemoryStream sw = new System.IO.MemoryStream();
using (var workbook = Packaging.SpreadsheetDocument.Create(sw, SpreadsheetDocumentType.Workbook)) {
var sheetData = CreateSheet(workbook);
while (reader.Read()) {
Spreadsheet.Row newRow = new Spreadsheet.Row();
foreach (string column in fields) {
Spreadsheet.Cell cell = new Spreadsheet.Cell();
cell.DataType = Spreadsheet.CellValues.String;
object value = null;
try {
int index = reader.GetOrdinal(column);
cell.DataType = DbKymosDomainService.ToXlsType(reader.GetFieldType(index));
value = DbKymosDomainService.ToStringFromCulture(reader.GetValue(index), reader.GetFieldType(index), Culture);
if (cell.DataType == Spreadsheet.CellValues.Number){
value = value == null ? "" : value.ToString().Replace(",", ".");
}
}
catch { }
cell.CellValue = new Spreadsheet.CellValue(value == null ? null : value.ToString()); //
newRow.AppendChild(cell);
try { var x = newRow.InnerXml; } catch { newRow.RemoveChild(cell); }
}
sheetData.AppendChild(newRow);
}
workbook.Close();
}
byte[] data = sw.ToArray();
sw.Close();
sw.Dispose();
return data;
}
Function which create sheet:
private Spreadsheet.SheetData CreateSheet(Packaging.SpreadsheetDocument workbook)
{
var workbookPart = workbook.AddWorkbookPart();
workbook.WorkbookPart.Workbook = new Spreadsheet.Workbook();
workbook.WorkbookPart.Workbook.Sheets = new Spreadsheet.Sheets();
var sheetPart = workbook.WorkbookPart.AddNewPart<Packaging.WorksheetPart>();
var sheetData = new Spreadsheet.SheetData();
sheetPart.Worksheet = new Spreadsheet.Worksheet(sheetData);
Spreadsheet.Sheets sheets = workbook.WorkbookPart.Workbook.GetFirstChild<Spreadsheet.Sheets>();
string relationshipId = workbook.WorkbookPart.GetIdOfPart(sheetPart);
uint sheetId = 1;
if (sheets.Elements<Spreadsheet.Sheet>().Count() > 0) {
sheetId =
sheets.Elements<Spreadsheet.Sheet>().Select(s => s.SheetId.Value).Max() + 1;
}
Spreadsheet.Sheet sheet = new Spreadsheet.Sheet() { Id = relationshipId, SheetId = sheetId, Name = "Export" };
sheets.Append(sheet);
return sheetData;
}
In my experience when a file needs to be repaired after creating it using OpenXML it means that it is missing a crucial element or the crucial element is in the wrong place. I'm having difficulty following your code so that in itself points to something being in the wrong place. Code should be sequential and self-explanatory. A few pointers however to help with getting to the root cause of your issue.
I would suggest first using ClosedXML as it takes so much strain out of the coding.https://github.com/closedxml/closedxml
Debug your code and step through each step to see what's going on.
Open the created file in OpenXML Productivity Tool https://github.com/OfficeDev/Open-XML-SDK/releases/tag/v2.5 and have a look around.
Another tool that I couldn't be without is OpenXML FileViewer: https://github.com/davecra/OpenXmlFileViewer
Lastly I always run this sub routine to validate documents I create using OpenXML:
public static List<string> ValidateWordDocument(FileInfo filepath, ref Int32 maxerrors = 100)
{
try
{
using (WordprocessingDocument wDoc = WordprocessingDocument.Open(filepath.FullName, false))
{
OpenXmlValidator validator = new OpenXmlValidator();
int count = 0;
List<string> er = new List<string>()
{
string.Format($"Assessment of {filepath.Name} on {DateTime.Now} yielded the following result: {Constants.vbCrLf}")
};
// set at zero so that we can determine the total quantity of errors
validator.MaxNumberOfErrors = 0;
// String.Format("<strong> Warning : </strong>")
foreach (ValidationErrorInfo error in validator.Validate(wDoc))
{
count += 1;
if (count > maxerrors)
break;
er.Add($"Error {count}{Constants.vbCrLf}" + $"Description {error.Description}{Constants.vbCrLf}" + $"ErrorType: {error.ErrorType}{Constants.vbCrLf}" + $"Node {error.Node}{Constants.vbCrLf}" + $"Name {error.Node.LocalName}{Constants.vbCrLf}" + $"Path {error.Path.XPath}{Constants.vbCrLf}" + $"Part: {error.Part.Uri}{Constants.vbCrLf}" + $"-------------------------------------------{Constants.vbCrLf}" + $"Outer XML: {error.Node.OuterXml}" + $"-------------------------------------------{Constants.vbCrLf}");
}
int validatorcount = validator.Validate(wDoc).Count;
switch (validatorcount)
{
case object _ when validatorcount > maxerrors:
{
er.Add($"Returned {count - 1} as this is the Maximum Number set by the system. The actual number of errors in {filepath.Name} is {validatorcount}");
er.Add("A summary list of all error types encountered is given below");
List<string> expectedErrors = validator.Validate(wDoc).Select(_e => _e.Description).Distinct().ToList();
er.AddRange(expectedErrors);
break;
}
case object _ when 1 <= validatorcount && validatorcount <= maxerrors:
{
er.Add($"Returned all {validator} errors in {filepath.Name}");
break;
}
case object _ when validatorcount == 0:
{
er.Add($"No Errors found in document {filepath.Name}");
break;
}
}
return er;
wDoc.Close();
}
}
catch (Exception ex)
{
Information.Err.MessageElevate();
return null;
}
}
It helps greatly with problem solving any potential issues.
I get that error along with this
Additional information: Invalid expression: [Invoice Date] = '01 / 11/2020 04:16:02 p.m. '
When filtering by date the other filters that are not date the filters works, this is what I use to put the filters in the datagridview:
BindingSource bs = new BindingSource();
bs.DataSource = oDsHDRCelMousClic.Tables[0];
oDsHDRCelMousClic.BeginInit();
grdDET.DataSource = bs;
foreach (DataGridViewColumn item in grdDET.Columns)
{
item.HeaderCell = new DataGridViewAutoFilterColumnHeaderCell(item.HeaderCell);
}
I imagine it is the date format but how do I change it? that brings it from the bd I think, because before the user selects the date of a datetimepicker and there is no time neither am nor pm only the date, that is a problem.
the other is that when you click on the filters some Chinese letters come out or I don't know where
chinese symbols
and in the first option, if I click on it, a box of more advanced filtering stuff comes out but everything is in Chinese or I don't know what language, the dll will download it from here https://www.nuget.org/packages/DataGridViewAutoFilter/1.0 .0 I imagine that there is the problem
chinese symbols
the third problem is that by clicking on the header of each column to sort the data the first 2 columns on the left side do work well and in the 5 also but in the others if I click it orders them but it does what I have on the CFD button on the right, this is the code when you click on the buttons
private void grdDET_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
//if (grdDET.Columns["CFD"].DisplayIndex == 8 || grdDET.Columns["Aperak"].DisplayIndex == 9)
//{
try
{
String Ruta = String.Empty;
String nombre_xml = String.Empty;
String strXML = String.Empty;
String Id_Cnsc_CFD = String.Empty;
//DataSet oDs = new DataSet();
String CadenaConexion = String.Empty;
#region Leemos Archivo de Configuración
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
XmlNode appSettingsNode =
xmlDoc.SelectSingleNode("configuration/userSettings/rutas");
if (appSettingsNode != null)
{
foreach (XmlNode node in appSettingsNode.ChildNodes)
{
string value = node.Attributes["value"].Value.ToString();
string keyName = node.Attributes["key"].Value.ToString();
if (keyName == "RutaArchivo")
Ruta = value;
}
if (false == Ruta.EndsWith("\\"))
{
Ruta += '\\';
}
if (Directory.Exists(Ruta) == false)
{
throw new Exception("No se encontró el directorio \"" + Ruta + "\".");
}
foreach (String xmls in Directory.GetFiles(Ruta))
{
FileInfo fi = new FileInfo(xmls);
if (fi.Extension.ToUpper() == ".XML")
{
File.Delete(fi.FullName);
}
}
}
else
{
throw new Exception("No se encontró el nodo \"rutas\".");
}
#endregion
//if (e.RowIndex >= 0)
//{
// DataGridViewRow row = grdHDR.Rows[e.RowIndex];
// grdDET.Text = row.Cells[0].Value.ToString();
// //txt3_prov.Text = row.Cells[4].Value.ToString();
//Id_Cnsc_CFD = e.ColumnIndex.Equals("Id_Cnsc_CFD").ToString().Trim();
//}
Id_Cnsc_CFD = grdDET.CurrentRow.Cells["Id_Cnsc_CFD"].Value.ToString().Trim();
try
{
sp = db.GetStoredProcCommand("eDocResumenEmisor_pUP");
db.AddInParameter(sp, "#pCveOperacion", DbType.String, "X");
db.AddInParameter(sp, "#pId_Cnsc_CFD", DbType.Int32, Id_Cnsc_CFD);
oDsDET = db.ExecuteDataSet(sp);
}
catch (Exception ex)
{
throw ex;
}
if (oDsDET.Tables.Count == 1)
{
if (oDsDET.Tables[0].Rows.Count == 1)
{
if (grdDET.CurrentCell.Value.ToString().Trim() == "CFD")
{
strXML = oDsDET.Tables[0].Rows[0]["XML"].ToString().Trim();
}
else if (grdDET.CurrentRow.Cells["Aperak"].Value.ToString().Trim() == "Aperak")
{
strXML = oDsDET.Tables[0].Rows[0]["Aperak"].ToString().Trim();
}
//if (grdDET.SelectedCells.Count > 0)
//{
// int selectedrowindex = grdDET.SelectedCells[0].RowIndex;
// DataGridViewRow selectedRow = grdDET.Rows[selectedrowindex];
// string a = Convert.ToString(selectedRow.Cells["CFD"].Value);
//}
//if (a == "CFD")
//{
// strXML = oDs.Tables[0].Rows[0]["XML"].ToString().Trim();
//}
//if (a == "Aperak")
//{
// strXML = oDs.Tables[0].Rows[0]["Aperak"].ToString().Trim();
//}
}
}
nombre_xml = System.Guid.NewGuid() + ".XML";
//Creamos el Archivo APERAK del error...
using (System.IO.FileStream fs = System.IO.File.Create(Ruta + nombre_xml, 1024))
{
// Add some information to the file.
byte[] info = new System.Text.UTF8Encoding(true).GetBytes(strXML);
fs.Write(info, 0, info.Length);
}
Process.Start(Ruta + nombre_xml);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
//}
}
PD I'm new to windows forms
Well, it turns out that I update or change the dll and it no longer shows me the Chinese symbols and keeps sending me the error but now in another class DataGridViewAutoFilterColumnHeaderCell.cs I imagine that this is the code you said #jfiggins
private void UpdateFilter()
{
// Continue only if the selection has changed.
if (dropDownListBox.SelectedItem.ToString().Equals(selectedFilterValue))
{
return;
}
// Store the new selection value.
selectedFilterValue = dropDownListBox.SelectedItem.ToString();
// Cast the data source to an IBindingListView.
IBindingListView data =
this.DataGridView.DataSource as IBindingListView;
Debug.Assert(data != null && data.SupportsFiltering,
"DataSource is not an IBindingListView or does not support filtering");
// If the user selection is (All), remove any filter currently
// in effect for the column.
if (selectedFilterValue.Equals("(All)"))
{
data.Filter = FilterWithoutCurrentColumn(data.Filter);
filtered = false;
currentColumnFilter = String.Empty;
return;
}
// Declare a variable to store the filter string for this column.
String newColumnFilter = null;
// Store the column name in a form acceptable to the Filter property,
// using a backslash to escape any closing square brackets.
String columnProperty =
OwningColumn.DataPropertyName.Replace("]", #"\]");
// Determine the column filter string based on the user selection.
// For (Blanks) and (NonBlanks), the filter string determines whether
// the column value is null or an empty string. Otherwise, the filter
// string determines whether the column value is the selected value.
switch (selectedFilterValue)
{
case "(Blanks)":
newColumnFilter = String.Format(
"LEN(ISNULL(CONVERT([{0}],'System.String'),''))=0",
columnProperty);
break;
case "(NonBlanks)":
newColumnFilter = String.Format(
"LEN(ISNULL(CONVERT([{0}],'System.String'),''))>0",
columnProperty);
break;
default:
newColumnFilter = String.Format("[{0}]='{1}'",
columnProperty,
((String)filters[selectedFilterValue])
.Replace("'", "''"));
break;
}
// Determine the new filter string by removing the previous column
// filter string from the BindingSource.Filter value, then appending
// the new column filter string, using " AND " as appropriate.
String newFilter = FilterWithoutCurrentColumn(data.Filter);
if (String.IsNullOrEmpty(newFilter))
{
newFilter += newColumnFilter;
}
else
{
newFilter += " AND " + newColumnFilter;
}
// Set the filter to the new value.
try
{
data.Filter = newFilter;
}
catch (InvalidExpressionException ex)
{
throw new NotSupportedException(
"Invalid expression: " + newFilter, ex);
}
// Indicate that the column is currently filtered
// and store the new column filter for use by subsequent
// calls to the FilterWithoutCurrentColumn method.
filtered = true;
currentColumnFilter = newColumnFilter;
}
here I get that error now
error
I did not do the sp but bring this:
SELECT
#Fec_Ini = CONVERT(DATETIME, CONVERT(VARCHAR(20), #pFec_Ini, 112) + ' 00:00:00')
,#Fec_Fin = CONVERT(DATETIME, CONVERT(VARCHAR(20), #pFec_Fin, 112) + ' 23:59:00')
I tried removing the minutes and seconds of the sp but it didn't work either
i am making a quiz application for my computing coursework and i am working on the end screen and in the end screen i have method called savescore()
the savescore() is meant to save the users' username,score and time into a text file. the savescore() method saves the users details into a text-file called scores perfectly but my problem is that when i write the user details into the text file i want the data to be written into the scores text file in order of descending score and i cant figure out how to do that.
private void SaveScore()
{
string file = #"..\..\textfiles\scores.txt";
try
{
//
// Create file if not exists
//
if (!File.Exists(file))
{
File.Create(file).Dispose();
}
//
// Create DataTable
//
DataColumn nameColumn = new DataColumn("name", typeof(String));
DataColumn scoreColumn = new DataColumn("score", typeof(int));
DataColumn timeColumn = new DataColumn("time", typeof(long));
DataTable scores = new DataTable();
scores.Columns.Add(nameColumn);
scores.Columns.Add(scoreColumn);
scores.Columns.Add(timeColumn);
//
// Read CSV and populate DataTable
//
using (StreamReader streamReader = new StreamReader(file))
{
streamReader.ReadLine();
while (!streamReader.EndOfStream)
{
String[] row = streamReader.ReadLine().Split(',');
scores.Rows.Add(row);
}
}
Boolean scoreFound = false;
//
// If user exists and new score is higher, update
//
foreach (DataRow score in scores.Rows)
{
if ((String)score["name"] == player.Name)
{
if ((int)score["score"] < player.Score)
{
score["score"] = player.Score;
score["time"] = elapsedtime;
}
scoreFound = true;
break;
}
}
//
// If user doesn't exist then add user/score
//
if (!scoreFound)
{
scores.Rows.Add(player.Name, player.Score, elapsedtime);
}
//
// Write changes to CSV (empty then rewrite)
//
File.WriteAllText(file, string.Empty);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("name,score,time");
foreach (DataRow score in scores.Rows)
{
stringBuilder.AppendLine(score["name"] + "," + score["score"] + "," + score["time"]);
}
File.WriteAllText(file, stringBuilder.ToString());
}
catch (Exception ex)
{
MessageBox.Show("Error saving high score:\n\n" + ex.ToString(), "Error");
}
}
so i someone could edit my current code to save the user details in descending order in terms of the score that would be fantastic and thanks in advance.
You can use the DataTable.Select method to achieve that. With the select method you can filter and sort the row in a table.
Here is the changed foreach statement that uses the method to sort the data.
foreach (DataRow score in scores.Select(null, "score DESC"))
{
stringBuilder.AppendLine(score["name"] + "," + score["score"] + "," + score["time"]);
}
Hi I'm using csvHelper to read in a csv files with a variable number of columns. The first row always contains a header row. The number of columns is unknown at first, sometimes there are three columns and sometimes there are 30+. The number of rows can be large.
I can read in the csv file, but how do I address each column of data. I need to do some basic stats on the data (e.g. min, max, stddev), then write them out in a non csv format.
Here is my code so far...
try{
using (var fileReader = File.OpenText(inFile))
using (var csvResult = new CsvHelper.CsvReader(fileReader))
{
// read the header line
csvResult.Read();
// read the whole file
dynamic recs = csvResult.GetRecords<dynamic>().ToList();
/* now how do I get a whole column ???
* recs.getColumn ???
* recs.getColumn['hadername'] ???
*/
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
Thanks
I don't think the library is capable of doing so directly. You have to read your column from individual fields and add them to a List, but the process is usually fast because readers do job fast. For example if your desired column is of type string, the code would be like so:
List<string> myStringColumn= new List<string>();
using (var fileReader = File.OpenText(inFile))
using (var csvResult = new CsvHelper.CsvReader(fileReader))
{
while (csvResult.Read())
{
string stringField=csvResult.GetField<string>("Header Name");
myStringColumn.Add(stringField);
}
}
using (System.IO.StreamReader file = new System.IO.StreamReader(Server.MapPath(filepath)))
{
//Csv reader reads the stream
CsvReader csvread = new CsvReader(file);
while (csvread.Read())
{
int count = csvread.FieldHeaders.Count();
if (count == 55)
{
DataRow dr = myExcelTable.NewRow();
if (csvread.GetField<string>("FirstName") != null)
{
dr["FirstName"] = csvread.GetField<string>("FirstName"); ;
}
else
{
dr["FirstName"] = "";
}
if (csvread.GetField<string>("LastName") != null)
{
dr["LastName"] = csvread.GetField<string>("LastName"); ;
}
else
{
dr["LastName"] = "";
}
}
else
{
lblMessage.Visible = true;
lblMessage.Text = "Columns are not in specified format.";
lblMessage.ForeColor = System.Drawing.Color.Red;
return;
}
}
}
I am trying to pass value from C# code to a CrystalReport report.
Edit
private void PrintOrder(List<OrderPrintBO> pListOrderBO)
{
DSOrderReport oDSOrderReport = new DSOrderReport();
DataTable oDataTable = oDSOrderReport.Tables[0];
String sOrderNo = "";
if (pListOrderBO.Count > 0)
{
for (int i = 0; i < pListOrderBO.Count; i++)
{
DataRow oRow = oDataTable.NewRow();
oRow["OrderID"] = pListOrderBO[i].OrderID;
oRow["OrderNumber"] = pListOrderBO[i].OrderNumber;
sOrderNo = pListOrderBO[i].OrderNumber;
oDataTable.Rows.Add(oRow);
}
}
oDSOrderReport.Merge(oDataTable);
oDSOrderReport.AcceptChanges();
if (oDSOrderReport.Tables[0].Rows.Count > 0)
{
// Main Copy
PrintDialog printDialog = new PrintDialog();
rptOrder oMainOrder = new rptOrder();
String sCompanyName = System.Configuration.ConfigurationManager.AppSettings["CompanyName"].ToString();
String sPhone1 = System.Configuration.ConfigurationManager.AppSettings["Phone1"].ToString();
String sPhone2 = System.Configuration.ConfigurationManager.AppSettings["Phone2"].ToString();
String sShowOrderNo = System.Configuration.ConfigurationManager.AppSettings["ShowOrderNo"].ToString();
((CrystalDecisions.CrystalReports.Engine.TextObject)oMainOrder.ReportDefinition.ReportObjects["txtCompanyName"]).Text = sCompanyName;
((CrystalDecisions.CrystalReports.Engine.TextObject)oMainOrder.ReportDefinition.ReportObjects["txtPhone1"]).Text = "Tel:" + sPhone1;
((CrystalDecisions.CrystalReports.Engine.TextObject)oMainOrder.ReportDefinition.ReportObjects["txtPhone2"]).Text = "Tel:" + sPhone2;
////This commented out section gives exception
//string sVarOrderNo = "";
//if (sShowOrderNo.ToLower() == "yes")
//{
// sVarOrderNo = sOrderNo;
//}
//((CrystalDecisions.CrystalReports.Engine.TextObject)oMainOrder.ReportDefinition.ReportObjects["txtOrderNo"]).Text = "O.N. : " + sVarOrderNo;
oMainOrder.SetDataSource(oDSOrderReport);
oMainOrder.PrintOptions.PrinterName = printDialog.PrinterSettings.PrinterName;
try
{
oMainOrder.PrintToPrinter(1, false, 0, 0);
MessageBox.Show("Order Printed Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
else
{
MessageBox.Show("Error in Printing Order", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
End Edit
For the first three text boxes (CompanyName, Phone1 & Phone2), every thing working just fine, but when I tried to pass the OrderNo to the report, Index was outside the bounds of the array. exception is occured, even though my report have a TextBox object named txtOrderNo
I am not sure why this is happening. Please help. Thanks.
Try to change your sOrderNo related code is as below.
string sVarOrderNo = "";
if (sShowOrderNo.ToLower() == "yes")
{
sVarOrderNo = sOrderNo;
}
((CrystalDecisions.CrystalReports.Engine.TextObject)oMainOrder.ReportDefinition.ReportObjects["txtOrderNo"]).Text = "O.N. : " + sVarOrderNo;
UPDATE
Your problem is below mentioned code snippet.Inside the for loop you try to assign a value to sOrderNo. Which is meaningless.B'cos it overrides every time when loop goes.So what is the purpose of this ? If you need this value then you have to bring this value through as your table's row or as a parameter to the report.
if (pListOrderBO.Count > 0)
{
for (int i = 0; i < pListOrderBO.Count; i++)
{
DataRow oRow = oDataTable.NewRow();
oRow["OrderID"] = pListOrderBO[i].OrderID;
oRow["OrderNumber"] = pListOrderBO[i].OrderNumber;
sOrderNo = pListOrderBO[i].OrderNumber;
oDataTable.Rows.Add(oRow);
}
}
I hope this will help to you.