![]() |
I am adding a new row to the datagrid dynamically but if i use the Count property of Item it is not showing the count of the new rows being added
here is the source code
private void AddRow() { TableCell tc = new TableCell(); tc.Controls.Add(new LiteralControl("NewRow")); DataGridItem di = new DataGridItem(DataGrid1.Items.Count+1,DataGrid1.Ite ms.Count+1,ListItemType.Item); di.Cells.Add(tc); di.Cells.Add(tc1); Table t = (Table)DataGrid1.Controls[0]; t.Rows.Add(di); } before i call this function, say i have 5 rows in my datagrid. After this function is called, which adds a new row to datagrid, still my datagrid shows it has only 5 rows....what could be the reason ----------------------- Posted by a user from .NET 247 (http://www.dotnet247.com/) <Id>S7kGQXam2kS4+j8Azj4KbA==</Id> |
Re: I am adding a new row to the datagrid dynamically but if i use the Count property of Item it is not showing the count of the new rows being added
"Praveen Balanagendra via .NET 247" <anonymous@dotnet247.com> wrote in
message news:e4LF2KzSEHA.3872@TK2MSFTNGP10.phx.gbl... > here is the source code > > private void AddRow() > { > TableCell tc = new TableCell(); > tc.Controls.Add(new LiteralControl("NewRow")); > > DataGridItem di = new DataGridItem(DataGrid1.Items.Count+1,DataGrid1.Ite ms.Count+1,ListItemType.It em); > di.Cells.Add(tc); > di.Cells.Add(tc1); > Table t = (Table)DataGrid1.Controls[0]; > t.Rows.Add(di); > } This code isn't adding rows to a datagrid, it's adding rows to a table which happens to be in the datagrid. Have you set the DataSource property of the datagrid? If so, then all the rows will come from the datasource, and the way to add a row to the grid would be to add the row to the source. -- John Saunders johnwsaundersiii at hotmail |
Re: I am adding a new row to the datagrid dynamically but if i use the Count property of Item it is not showing the count of the new rows being added
"Praveen Balanagendra via .NET 247" <anonymous@dotnet247.com> wrote in
message news:e4LF2KzSEHA.3872@TK2MSFTNGP10.phx.gbl... > here is the source code > > private void AddRow() > { > TableCell tc = new TableCell(); > tc.Controls.Add(new LiteralControl("NewRow")); > > DataGridItem di = new DataGridItem(DataGrid1.Items.Count+1,DataGrid1.Ite ms.Count+1,ListItemType.It em); > di.Cells.Add(tc); > di.Cells.Add(tc1); > Table t = (Table)DataGrid1.Controls[0]; > t.Rows.Add(di); > } > > before i call this function, say i have 5 rows in my datagrid. After this function is called, which adds a new row to datagrid, still my datagrid shows it has only 5 rows....what could be the reason 1) AddRow() is never called 2) DataBind() is being called after AddRow() 3) I'm not sure this could be the reason, but try: new DataGridItem(DataGrid1.Items.Count+1,0,ListItemTyp e.Item); -- Jos |
| All times are GMT. The time now is 07:05 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.