hi friends,
i have got a small problem
I want to add a new row to the Datagrid(not bound to nay database table) when i select any value from a dropdownlist(which is in one of the columns of the datagrid) such that the previous rows should maintain their value as before and only a new row is added.
i am pasting the code chunk below
please tell me what is going wrong because the row gwets added only once and no event is fired second time
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
Table1 = new Table();
TableRow row = new TableRow();
Table1.Rows.Add (row);
DataGrid1.DataSource=Table1.Rows;
DataGrid1.DataBind();
}
}
protected void dd1_SelectedIndexChanged(object sender, EventArgs e)
{
DataGridItem dgi = (DataGridItem)(((Control)sender).NamingContainer);
DropDownList ddl = (DropDownList) dgi.Cells[0].Controls[1];
DataGrid dg =(DataGrid) dgi.Parent.Parent;
TableCell tc = new TableCell();
Label l1 = new Label();
l1.Text ="hi";
tc.Controls.Add(l1);
DataGridItem dgItem = new DataGridItem(dgi.ItemIndex+1,0,ListItemType.Item);
dgItem.Cells.Add(tc);
DataGrid1.Controls[0].Controls.AddAt(dgi.ItemIndex+1,dgItem);
}