hello all,

i need urgent help here. My project is stuck up due to this.
Help appriciated.
ERROR MESSAGE:-
System.NullReferenceException: Object reference not set to an instance
of an object. at DSeditDB.WebForm1.Update_Command(Object sender,
DataGridCommandEventArgs e) 

Error throw while using findbyid with dataset row.. it seems no row is
selected.

DATASET , SQLADAPTER , CONNECTION STRING MADE AT DESIGN TIME

DATASET : Datasetname:-DataSet1                                  
Designname:- dataSet11

code:_

private void Page_Load(object sender, System.EventArgs e)
                {       
                        if (!IsPostBack)
                        {
                                BindData();
                        }

                }
                public void BindData()
                {
                        sqlDataAdapter1.Fill(dataSet11);
                        DataGrid1.DataBind();
                }

                public void Edit_Command(object sender , 
DataGridCommandEventArgs e)
                {
                        DataGrid1.EditItemIndex= e.Item.ItemIndex;
                        BindData();
                }
                public void Update_Command(object sender , 
DataGridCommandEventArgs e)
                {
                        DataGrid1.EditItemIndex=(int) e.Item.ItemIndex;
                        TextBox tb;
                        string ID_copy = e.Item.Cells[4].Text;
                        int ID = System.Int32.Parse(ID_copy);

                        tb = (TextBox)e.Item.Cells[2].Controls[0];
                        int Age = System.Int32.Parse(tb.Text);
                        
                        tb = (TextBox)e.Item.Cells[1].Controls[0];
                        string Name = tb.Text;  
                        Name = Name.Trim();
                                        
                        tb = (TextBox)e.Item.Cells[3].Controls[0];
                        string Address = tb.Text;       
                        Address = Address.Trim();

                        //DataSet1.table1Row RowChange = 
dataSet11.table1.FindByID(3);

                        DataSet1.table1Row RowChange; 
                        RowChange= null;
                        // Get the row to change using the primary key.
                        RowChange =dataSet11.table1.FindByID(ID);
                        // Change a field in the row.
                        try
                        {
                                RowChange.address="changed";
                        }
                        catch (Exception ex)
                        {
                                Label1.Text = ex.ToString();
                        }
                        DataGrid1.EditItemIndex= -1;
                        BindData();
                }
                public void Cancel_Command(object sender , 
DataGridCommandEventArgs e)
                {
                        DataGrid1.EditItemIndex = -1;
                        BindData();
                }










------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




Reply via email to