Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Building Controls (http://www.velocityreviews.com/forums/f59-asp-net-building-controls.html)
-   -   FindControl Method always returns empty string!!!!! (http://www.velocityreviews.com/forums/t757910-findcontrol-method-always-returns-empty-string.html)

steroche 08-25-2005 12:12 AM

FindControl Method always returns empty string!!!!!
 
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


steroche 08-25-2005 01:44 AM

Re: FindControl Method always returns empty string!!!!!
 
Please Help Me!!! :- (


steroche 08-25-2005 03:15 AM

Re: FindControl Method always returns empty string!!!!!
 
One problem down, was rebinding old data each time i went to upload- in
the DataGrid1_EditCommand - which is odd,didn't think that would effect
the subsequent DataGrid1_UpdateCommand but evidently it does!



All times are GMT. The time now is 04:21 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.