Click here to Skip to main content
14,325,916 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

Here is another solution

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

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



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

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100