using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OracleClient;
public partial class _Default : System.Web.UI.Page 
{
    OracleConnection objConn;
    OracleCommand objCmd;
    String strSQL;

    protected void Page_Load(object sender, EventArgs e)
    {
String strConnString;         
strConnString = "Data Source=pcrm195;User Id=wllnew;Password=wllnew;";         
objConn = new OracleConnection(strConnString);        
objConn.Open();         
if (!Page.IsPostBack)         
{             
BindData();        
} 
    }
    protected void BindData()
    {
        String strSQL;
        strSQL = "SELECT * FROM WLLPACKAGE";

        OracleDataReader dtReader;

        objCmd = new OracleCommand(strSQL, objConn);

        dtReader = objCmd.ExecuteReader();

        //*** BindData to DataGrid ***// 

        myDataGrid.DataSource = dtReader;
        myDataGrid.DataBind();
        dtReader.Close();
        dtReader = null;
    }

 protected void  myDataGrid_CancelCommand(object sender, DataGridCommandEventArgs e)
{
myDataGrid.EditItemIndex = -1;        
myDataGrid.ShowFooter = true;        
BindData(); 
}
protected void  myDataGrid_EditCommand(object sender, DataGridCommandEventArgs e)
{
myDataGrid.EditItemIndex = e.Item.ItemIndex;        
myDataGrid.ShowFooter = false;        
BindData();
}
    protected void myDataGrid_DeleteCommand(object sender, DataGridCommandEventArgs e)
{
strSQL = "DELETE FROM WLLPACKAGE WHERE WLLPACKAGEID = '" + myDataGrid.DataKeys[e.Item.ItemIndex]+"'";        
objCmd = new OracleCommand(strSQL, objConn);       
objCmd.ExecuteNonQuery();           
myDataGrid.EditItemIndex = -1;      
BindData();
}
    protected void myDataGrid_UpdateCommand(object sender, DataGridCommandEventArgs e)
{
TextBox txtWLLPACKAGEID = (TextBox)e.Item.FindControl("txtEditWLLPACKAGEID"); 

TextBox txtWLLPACKAGECODE = (TextBox)e.Item.FindControl("txtWLLPACKAGECODE"); 

TextBox txtWLLPACKAGENAME = (TextBox)e.Item.FindControl("txtEditWLLPACKAGENAME"); 
TextBox txtWLLPACKAGEDESC = (TextBox)e.Item.FindControl("txtEditWLLPACKAGEDESC");        
TextBox txtSDATE = (TextBox)e.Item.FindControl("txtSDATE");         
TextBox txtEDATE = (TextBox)e.Item.FindControl("txtEditEDATE");
TextBox txtSTATUS = (TextBox)e.Item.FindControl("txtEditSTATUS");
TextBox txtBRANDID = (TextBox)e.Item.FindControl("txtEditBRANDID"); 

strSQL = "UPDATE WLLPACKAGE SET WLLPACKAGEID = '" + txtWLLPACKAGEID.Text + "' " +            
" ,WLLPACKAGECODE = '" + txtWLLPACKAGECODE.Text + "' " +
  " ,WLLPACKAGENAME = '" + txtWLLPACKAGENAME.Text + "' " +           
" ,WLLPACKAGEDESC = '" + txtWLLPACKAGEDESC.Text + "' " +            
" ,SDATE= '" + txtSDATE.Text + "' " +           
" ,EDATE= '" + txtEDATE.Text + "' " +           
" ,STATUS= '" + txtSTATUS.Text + "' " +            
" ,BRANDID = '" + txtBRANDID.Text + "' " +           
" WHERE WLLPACKAGEID = '" + myDataGrid.DataKeys[e.Item.ItemIndex] + "'";        
objCmd = new OracleCommand(strSQL, objConn);       
objCmd.ExecuteNonQuery(); 
myDataGrid.EditItemIndex = -1;        
myDataGrid.ShowFooter = true;         
BindData();        
}
    protected void myDataGrid_ItemCommand(object sender, DataGridCommandEventArgs e)
{
    if (e.CommandName == "Add")
    {

        TextBox txtWLLPACKAGEID = (TextBox)e.Item.FindControl("txtAddWLLPACKAGEID");

        TextBox txtWLLPACKAGECODE = (TextBox)e.Item.FindControl("txtAddWLLPACKAGECODE");

        TextBox txtWLLPACKAGENAME = (TextBox)e.Item.FindControl("txtAddWLLPACKAGENAME");

        TextBox txtWLLPACKAGEDESC = (TextBox)e.Item.FindControl("txtAddWLLPACKAGEDESC");

        TextBox txtSDATE = (TextBox)e.Item.FindControl("txtAddSDATE");

        TextBox txtEDATE = (TextBox)e.Item.FindControl("txtAddEDATE");
        TextBox txtSTATUS = (TextBox)e.Item.FindControl("txtAddSTATUS");
        TextBox txtBRANDID = (TextBox)e.Item.FindControl("txtAddBRANDID");

        strSQL = "INSERT INTO WLLPACKAGE (WLLPACKAGEID,WLLPACKAGECODE,WLLPACKAGENAME,WLLPACKAGEDESC,SDATE,EDATE,STATUS,BRANDID) " +

        " VALUES ('" + txtWLLPACKAGEID.Text + "','" + txtWLLPACKAGECODE.Text + "','" + txtWLLPACKAGENAME.Text +"','" + txtWLLPACKAGEDESC.Text + "','" + txtSDATE.Text + "','" + txtEDATE.Text + "','" + txtSTATUS.Text + "','" + txtBRANDID.Text + "')";

        objCmd = new OracleCommand(strSQL, objConn);

        objCmd.ExecuteNonQuery();

        BindData(); 
}



}


}

It's difficult from your code to find out from where error is occuring.But i believe , it's from UpdateCommand or ItemCommand event. Just make sure the name you have defined for textboxes is spell correctly in both the above mentioned event.

Another thing, on your Visual studion IDE, Press Alt + Ctrl + E. Then check the checkbox under Thrown Column for Common Language Runtime Exception option. So that it will redirect you on the correct place from where the error is occuring and it will become easy for you to identify the root cause of error.

Do this and let us know..

Without seeing the meat of the actual error (90% of the time if you set the page to debug mode it will show you the line of code where the error is occurring) it's hard to say for sure but...

As a potentially unrelated side-note, were you aware that you have declared String strSQL; as both a global and a local variable (within BindData()) and appear to have initialized it in BindData() and myDataGrid_DeleteCommand/myDataGrid_UpdateCommand/myDataGrid_ItemCommand.

I'm also surprised you didn't get any errors in your global declarations of your connection and command parameters as ASP.Net tends to get picky about setting global variable permissions and such (private, public, static, etc) I wouldn't be surprised if part of the issue comes from an undeclared (at the time of use) objConn variable in one of your delete/update/item procedures.

Hope this helps somewhat, but again a more detailed error message would help pinpoint it more accurately. You can usually enable debug mode on just one page of your app by inserting the debug code at the top of the ASPX page.

this error occurs when in the table the null value doesn't exist but in the coding side null value passes.
so check the table and debug the code with f11 u will surely find out frm where the error occurs

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.