473,322 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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>
Nov 18 '05 #1
2 1934
"Praveen Balanagendra via .NET 247" <an*******@dotnet247.com> wrote in
message news:e4**************@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
Nov 18 '05 #2
Jos
"Praveen Balanagendra via .NET 247" <an*******@dotnet247.com> wrote in
message news:e4**************@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
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
2
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
0
by: Sileesh | last post by:
Hi I have html table and a Button in an Aspx page. I am adding one row with some textboxes to Html table each time i click on the Button thru Javascript. Now problem is when when i try to...
4
by: Steve | last post by:
I am fairly new to VB.NET, and I am rewriting an application I wrote a while back, also in VB.NET. I aplied some new things I learned. Anyway, here is my problem....... I have a custom DataGrid...
0
by: Guy W via DotNetMonster.com | last post by:
I read and tried to use the repeater paging method I found on 4 Guys from Rolla (I've tried others also) but it doesn't seem to work. Please see the code I have below and tell me what I may be...
0
by: Matt | last post by:
I derived my own custom class from the datagrid class. I overrode the ProcessCmdKey Function, like this, to catch the up and down arrow keys: ====== Protected Overrides Function...
1
by: sp | last post by:
Hello I have a problem with the refresh performance in datagrid – when datagrid is being shown it is so slow that I can see one by one cells is drawn -datagrid contains about 35x40 of...
12
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.