PC Review


Reply
Thread Tools Rate Thread

adding a row on a datagrid

 
 
rcoco
Guest
Posts: n/a
 
      26th Feb 2007
Hi,
I'm trying to Insert a new Row on a dagrid. When I did a google
search, I got an example on this address: http://www.codeproject.com/ASPNET_DataGrid.asp.
I've done mycode as follows:

private void Fill()
{
DataSet ds=new DataSet();
SqlDataAdapter adapter =new SqlDataAdapter("select * from DashBoard",
con);
adapter.Fill(ds);
}
private void Bind()
{
DataSet ds=new DataSet();
dgis.DataSource = ds;
dgis.DataBind();
}
private void InsertEmpty()
{
DataSet table=new DataSet();
Table.Rows.InsertAt(Table.NewRow(), 0);
}
private void bttnew_Click(object sender, System.EventArgs e)
{

dgis.EditItemIndex = 0;

EditCommandColumn ecc = (EditCommandColumn) dgis.Columns[0];
ecc.UpdateText = "Insert";

Fill();
InsertEmpty();
Bind();
}
private void dgis_ItemCommand(object
source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
dgis.EditItemIndex = -1;
switch (e.CommandName)
{
case "Insert":
break;

case "Update":
break;

case "Cancel":
EditCommandColumn ecc =(EditCommandColumn) dgis.Columns[0];
ecc.UpdateText = "Update";
break;

case "Edit":
dgis.EditItemIndex = e.Item.ItemIndex;
break;
}

Fill();
Bind();
}

On compiling I get this error

-'System.Web.UI.WebControls.Table' does not contain a definition for
'NewRow'
-'System.Web.UI.WebControls.TableRowCollection' does not contain a
definition for 'InsertAt'
-'An object reference is required for the nonstatic field, method, or
property 'System.Web.UI.WebControls.Table.Rows'

Where could I be going wrong?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding new row to datagrid vbtrying Microsoft C# .NET 2 8th Jan 2008 01:06 PM
Adding value to datagrid Cell while Adding a New Row in VB.Net 2005 Luqman Microsoft VB .NET 0 18th Apr 2007 03:07 PM
Adding row at the top of a datagrid =?Utf-8?B?R2lyZWVzaCBLdW1hcg==?= Microsoft C# .NET 1 25th May 2004 02:16 PM
Adding two a Datagrid Gerry Viator Microsoft ADO .NET 8 5th May 2004 01:10 PM
DataGrid- Adding a new row in the middle of the datagrid Seth Broomer Microsoft ASP .NET 1 24th Mar 2004 08:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:18 AM.