R
rcoco
Hi,
I have a datagrid that is ment to insert data. But when I run the form
only the header appears. I would like some advise from you all and
solve this problem I'm using visual studio 2003. My code looks like
this:
private void Fill()
{
DataTable table = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * from
dbo.DashBoard", con);
adapter.Fill(table);
}
private void Bind()
{
DataTable table = new DataTable();
dgis.DataSource = table;
dgis.DataBind();
}
private void InsertEmpty()
{
DataTable table = new DataTable();
table.Rows.InsertAt(table.NewRow(), 0);
}
private void bttnew_Click(object sender, System.EventArgs e)
{
// inserting
dgis.EditItemIndex = 0;
// modify text
EditCommandColumn ecc = (EditCommandColumn) dgis.Columns[5];
ecc.UpdateText = "Insert";
EditCommandColumn ecc1 =(EditCommandColumn) dgis.Columns[4];
ecc.UpdateText = "Insert";
// fill table, insert empty row, bind to datagrid
Fill();
InsertEmpty();
Bind();
}
private void dgis_ItemCommand(object
source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
// stop editing
dgis.EditItemIndex = -1;
switch (e.CommandName)
{
case "Insert":
break;
case "Update":
break;
case "Cancel":
EditCommandColumn ecc =(EditCommandColumn) dgis.Columns[0];
ecc.UpdateText = "Update";
EditCommandColumn ecc1 =(EditCommandColumn) dgis.Columns[0];
ecc.UpdateText = "Update";
break;
case "Edit":
// begin editing
dgis.EditItemIndex = e.Item.ItemIndex;
break;
}
// fill and bind
Fill();
Bind();
}
I have a datagrid that is ment to insert data. But when I run the form
only the header appears. I would like some advise from you all and
solve this problem I'm using visual studio 2003. My code looks like
this:
private void Fill()
{
DataTable table = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * from
dbo.DashBoard", con);
adapter.Fill(table);
}
private void Bind()
{
DataTable table = new DataTable();
dgis.DataSource = table;
dgis.DataBind();
}
private void InsertEmpty()
{
DataTable table = new DataTable();
table.Rows.InsertAt(table.NewRow(), 0);
}
private void bttnew_Click(object sender, System.EventArgs e)
{
// inserting
dgis.EditItemIndex = 0;
// modify text
EditCommandColumn ecc = (EditCommandColumn) dgis.Columns[5];
ecc.UpdateText = "Insert";
EditCommandColumn ecc1 =(EditCommandColumn) dgis.Columns[4];
ecc.UpdateText = "Insert";
// fill table, insert empty row, bind to datagrid
Fill();
InsertEmpty();
Bind();
}
private void dgis_ItemCommand(object
source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
// stop editing
dgis.EditItemIndex = -1;
switch (e.CommandName)
{
case "Insert":
break;
case "Update":
break;
case "Cancel":
EditCommandColumn ecc =(EditCommandColumn) dgis.Columns[0];
ecc.UpdateText = "Update";
EditCommandColumn ecc1 =(EditCommandColumn) dgis.Columns[0];
ecc.UpdateText = "Update";
break;
case "Edit":
// begin editing
dgis.EditItemIndex = e.Item.ItemIndex;
break;
}
// fill and bind
Fill();
Bind();
}