subh

subh

  • NA
  • 2
  • 0

datagrid datasource error

Mar 13 2007 10:05 AM
In my application iam using a public function binding which is for binding dataset to datagrid in webform1. I am calling this fuction from another web form say webform2. I got error in Datagrid1.Datasource
line saying {"Object reference not set to an instance of an object." }
I am not passing dataset . Just calling the binding function which
runs query, fill dataset & set the datasource of datagrid to dataset.


webform1:

public void binding()
{try
{someclass objsomeclass= new someclass();
DataGrid1.DataSource=someclass.somefunction();
DataGrid1.DataBind();
}
catch(Exception exc)

{ Response.Write(exc.Message);}
}


this function is working fine in webform1 . But when i call this function from webform2 , datagrid.Datasource throws error .


webform2 button click:

webform1 objwebform1 =new webform1();

objwebform1.binding();


pls let me know where i am going wrong....

Thanks .