Click here to Skip to main content
15,885,886 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear All

I have attached an Excel sheet value with data set now i want to check each cell value of excel sheet wheather is NULL or Not.Kindly help as soon as possible

Thanks in advance

Thanks & Reagrds
Maheswar Tripathy
Posted
Comments
Naz_Firdouse 19-Aug-13 6:11am    
what have you tried???
jaideepsinh 19-Aug-13 6:39am    
Paste you code here.
Maheswar Tripathy 20-Aug-13 4:31am    
if (dsm.Tables[3].Rows.Count > 0)
{
int i = 0;
DataTable sco = dsm.Tables[3];
foreach (DataRow row in sco.Rows)
{
//lblMessage.Text = dsm.Tables[3].Rows[i]["Cust_Name"].ToString();
//lblMessage.Text= (Convert.ToInt32(dsm.Tables[3].Rows[i]["Credit_Check"]).ToString());
if (dsm.Tables[3].Rows[i]["Cust_Name"] != DBNull.Value && Convert.ToInt32(dsm.Tables[3].Rows[i]["Credit_Check"]) != 0)
{
divARIssue.Visible = true;
lblMessage.Visible = true;
btnReport.Enabled = false;
gvARIssue.DataSource = dsm.Tables[3];
gvARIssue.DataBind();
DateTime e_date = Convert.ToDateTime(dsm.Tables[3].Rows[16]["BaseLine_Date"].ToString());
lblMessage.Text = String.Format("{0:dd MMM yyyy}", e_date);


}
else if (dsm.Tables[3].Rows[i]["Cust_Name"] == DBNull.Value || Convert.ToInt32(dsm.Tables[3].Rows[i]["Credit_Check"]) != 0)
{
string abc = dsm.Tables[3].Rows[i]["Cust_Code"].ToString();
lblMessage.Text = "Customer not present in master for existing Customer code"+(abc);
divARIssue.Visible = true;
lblMessage.Visible = true;
btnReport.Enabled = false;
gvARIssue.DataSource = null;
gvARIssue.DataBind();
//break;

}
else if(dsm.Tables[3].Rows[i]["Cust_Name"] != DBNull.Value || Convert.ToInt32(dsm.Tables[3].Rows[i]["Credit_Check"]) == 0)
{
string abc = dsm.Tables[3].Rows[i]["Cust_Code"].ToString();
lblMessage.Text = "No Credit term for Exsiting Customer in master"+ (abc);
divARIssue.Visible = true;
lblMessage.Visible = true;
btnReport.Enabled = false;
gvARIssue.DataSource = null;
gvARIssue.DataBind();
//break;

}
else
{
divARIssue.Visible = true;
lblMessage.Visible = true;
btnReport.Enabled = false;
gvARIssue.DataSource = null;
gvARIssue.DataBind();

}
i++;
}

}



The above is my code i have to check two column value and show the error list according to the data match to the condition
VICK 19-Aug-13 6:40am    
Kindly post your code snippet so that solution could be provided accordingly....

Further kindly tell that which API you are using for excel manipulation???
You should try something and then come back with some code here.

1 solution

Here is another solution

C#
for (int i = 0; i < table.Rows.Count; i++)
            {

                if (table.Rows[i]["Employee"] == DBNull.Value)
                {
                    string s = string.Empty;
                }



            }
 
Share this answer
 
v3
Comments
Mukesh Ghosh 19-Aug-13 6:23am    
If you can fetch data into Data Table then next part is to check null you can go the block i have attached. For each cell you need to check above.
Maheswar Tripathy 19-Aug-13 6:27am    
Dear Mukesh Ghosh

Very sorry to say that it throws some error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900