-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Mess_With_The_Bestone
Message 1 in Discussion

Hi frends  there is a problem while I am updating data back into the dataset 
from the Datagrid.
It would be gr8 if some can help me out in solving this problem
 The following is the code which i have written in the Update Command      
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As 
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles 
DataGrid1.UpdateCommand<o:p></o:p> 
<o:p> </o:p> 
  Dim key As String = CStr(e.Item.ItemIndex)<o:p></o:p> 
  Dim CustomerID, CompanyName, ContactName, ContactTitle As String<o:p></o:p> 
  Dim tb As System.Web.UI.WebControls.TextBox<o:p></o:p> 
               
tb=CType(e.Item.Cells(1).Controls(0),System.Web.UI.WebControls.TextBox)<o:p></o:p>
 
CustomerID = tb.Text<o:p></o:p> 
tb=CType(e.Item.Cells(2).Controls(0),System.Web.UI.WebControls.TextBox)<o:p></o:p>
 
CompanyName = tb.Text<o:p></o:p> 
tb=CType(e.Item.Cells(3).Controls(0),System.Web.UI.WebControls.TextBox)<o:p></o:p>
 
ContactName = tb.Text<o:p></o:p> 
tb=CType(e.Item.Cells(4).Controls(0),System.Web.UI.WebControls.TextBox)<o:p></o:p>
 
ContactTitle = tb.Text<o:p></o:p> 
<o:p> </o:p> 
  Dim r As mynewdataset.CustomersRow<o:p></o:p> 
      r = Mynewdataset1.Customers.FindByCustomerID(key) 
       
      'Source of Error at this point<o:p></o:p> 
      r.CustomerID = CustomerID<o:p></o:p> 
      r.CompanyName = CompanyName<o:p></o:p> 
      r.ContactName = ContactName<o:p></o:p> 
      r.ContactTitle = ContactTitle<o:p></o:p> 
<o:p> </o:p> 
SqlDataAdapter1.Update(Mynewdataset1)<o:p></o:p> 
DataGrid1.DataBind()<o:p></o:p> 
<o:p> </o:p> 
�For Removing the Selected row from the edition mode<o:p></o:p> 
DataGrid1.EditItemIndex = -1<o:p></o:p> 
End Sub 
<o:p></o:p>  
<o:p>The Following is the Error message which I am getting</o:p><o:p> Object 
reference not set to an instance of an object. <o:p></o:p> 
Description: An unhandled exception occurred during the execution of the 
current web request. Please review the stack trace for more information about 
the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to 
an instance of an object.

Source Error: <o:p></o:p> 
    <o:p> </o:p>Line 199:        r = 
Mynewdataset1.Customers.FindByCustomerID(key)<o:p></o:p>Line 
200:<o:p></o:p>Line 201:        r.CustomerID = CustomerID<o:p></o:p>Line 202:   
     r.CompanyName = CompanyName<o:p></o:p>Line 203:        r.ContactName = 
ContactName<o:p></o:p> 

Source File: c:\inetpub\wwwroot\aspcustomcontrol\mydatadisplay.aspx.vb    Line: 
201</o:p> 
<o:p></o:p>  
<o:p></o:p>  
<o:p>Thanks in advance</o:p> 
<o:p>Shiva</o:p>

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to