S
steroche
Hi guys - Can somebody please help me?
I'm a novice at all thisIve run into a serious stumbling block for the
last few hours now and its killing me!
I have a paged/sorted Datagrid setup and it works fine except for the
update method - i just cannot get it to work!
Now i keep getting the error :
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object
on line
Line 486: this.dsGarda.Tables["Garda"].Rows[e.Item.ItemIndex][3]
= newCaseID;
Here is my update method:
private void dgGarda_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string newCaseID, newStationID = null;
string newLname,newRank,newArea = null;
TextBox tb;
//all tb.Text vals = "" below
tb =
(TextBox)(dgGarda.Items[dgGarda.EditItemIndex].FindControl("txtEditCase"));
newCaseID = tb.Text.ToString();
tb =
(TextBox)(dgGarda.Items[dgGarda.EditItemIndex].FindControl("txtEditStation"));
newStationID = tb.Text;
tb =
(TextBox)(dgGarda.Items[dgGarda.EditItemIndex].FindControl("txtEditRank"));
newRank = tb.Text;
tb =
(TextBox)(dgGarda.Items[dgGarda.EditItemIndex].FindControl("txtEditArea"));
newArea = tb.Text;
this.dsGarda.Tables[1].Rows[e.Item.ItemIndex][3] = newCaseID;
this.dsGarda.Tables["Garda"].Rows[e.Item.ItemIndex][4] = newStationID;
this.dsGarda.Tables["Garda"].Rows[e.Item.ItemIndex][5] =
newRank;this.dsGarda.Tables["Garda"].Rows[e.Item.ItemIndex][6] =
newArea;
this.daGarda.Update(dsGarda, "Garda");
dgCase.EditItemIndex = -1;
dgCase.DataBind();
}
When i step through the code i see that all my FindControl methods are
returning empty strings aswell!!Anybody have any idea whats going on??I
read somewhere i should have the datagrid.databind call in the if
(!IsPostBack) but when i did this it didn't reload the grid when i
clicked edit.
Any help is greatly appreciated as i think i am going to kill my
computer shortly if i cant fix this!!!
Thanks,
Steve
I'm a novice at all thisIve run into a serious stumbling block for the
last few hours now and its killing me!
I have a paged/sorted Datagrid setup and it works fine except for the
update method - i just cannot get it to work!
Now i keep getting the error :
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object
on line
Line 486: this.dsGarda.Tables["Garda"].Rows[e.Item.ItemIndex][3]
= newCaseID;
Here is my update method:
private void dgGarda_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string newCaseID, newStationID = null;
string newLname,newRank,newArea = null;
TextBox tb;
//all tb.Text vals = "" below
tb =
(TextBox)(dgGarda.Items[dgGarda.EditItemIndex].FindControl("txtEditCase"));
newCaseID = tb.Text.ToString();
tb =
(TextBox)(dgGarda.Items[dgGarda.EditItemIndex].FindControl("txtEditStation"));
newStationID = tb.Text;
tb =
(TextBox)(dgGarda.Items[dgGarda.EditItemIndex].FindControl("txtEditRank"));
newRank = tb.Text;
tb =
(TextBox)(dgGarda.Items[dgGarda.EditItemIndex].FindControl("txtEditArea"));
newArea = tb.Text;
this.dsGarda.Tables[1].Rows[e.Item.ItemIndex][3] = newCaseID;
this.dsGarda.Tables["Garda"].Rows[e.Item.ItemIndex][4] = newStationID;
this.dsGarda.Tables["Garda"].Rows[e.Item.ItemIndex][5] =
newRank;this.dsGarda.Tables["Garda"].Rows[e.Item.ItemIndex][6] =
newArea;
this.daGarda.Update(dsGarda, "Garda");
dgCase.EditItemIndex = -1;
dgCase.DataBind();
}
When i step through the code i see that all my FindControl methods are
returning empty strings aswell!!Anybody have any idea whats going on??I
read somewhere i should have the datagrid.databind call in the if
(!IsPostBack) but when i did this it didn't reload the grid when i
clicked edit.
Any help is greatly appreciated as i think i am going to kill my
computer shortly if i cant fix this!!!
Thanks,
Steve