Here i am try to inserting Data into array,but here Iam getting bellow Error Object reference not set to an instance of an object. how can i insert Data into array using loop.
String[][] data = new String[gvDetails.Rows.Count][];
{
for (rowIndex = 0; rowIndex < gvDetails.Rows.Count; rowIndex++)
{
for (int k = 0; k < gvDetails.Columns.Count; k++)
{
string Data1=DataTable1.Rows[rowIndex][k].ToString();
data[rowIndex][k] = Data1;
}
}
Each row in the jagged array is set to null initially and needs to be initialized:
for (rowIndex = 0; rowIndex < gvDetails.Rows.Count; rowIndex++)
{
data[rowIndex] = new String[gvDetails.Columns.Count];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.