R
rcoco
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?
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?