It may be that my coffee hasn't kicked in this morning, but I can't
find a method called FindByID anywhere in the .NET Framework, much
less on the DataTable class. This appears to be a custom method you
are calling on a class that inherits from DataTable. I'd check that
the method is working properly. If it is, I'd also check that you
a) have rows in the table
b) are capturing the ID properly from the grid.
On 10/13/05, rajan_bhayana_groups <[EMAIL PROTECTED]> wrote:
> 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 Links
>
>
>
>
>
>
>
>
>
--
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/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/