473,563 Members | 2,767 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Da taGrid1.Items.C ount+1,DataGrid 1.Items.Count+1 ,ListItemType.I tem);
di.Cells.Add(tc );
di.Cells.Add(tc 1);
Table t = (Table)DataGrid 1.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>S7kGQXam2kS 4+j8Azj4KbA==</Id>
Nov 18 '05 #1
2 1955
"Praveen Balanagendra via .NET 247" <an*******@dotn et247.com> wrote in
message news:e4******** ******@TK2MSFTN GP10.phx.gbl...
here is the source code

private void AddRow()
{
TableCell tc = new TableCell();
tc.Controls.Add (new LiteralControl( "NewRow"));

DataGridItem di = new DataGridItem(Da taGrid1.Items.C ount+1,DataGrid 1.Items.Count+1 ,ListItemType.I t
em); di.Cells.Add(tc );
di.Cells.Add(tc 1);
Table t = (Table)DataGrid 1.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
johnwsaundersii i at hotmail
Nov 18 '05 #2
Jos
"Praveen Balanagendra via .NET 247" <an*******@dotn et247.com> wrote in
message news:e4******** ******@TK2MSFTN GP10.phx.gbl...
here is the source code

private void AddRow()
{
TableCell tc = new TableCell();
tc.Controls.Add (new LiteralControl( "NewRow"));

DataGridItem di = new DataGridItem(Da taGrid1.Items.C ount+1,DataGrid 1.Items.Count+1 ,ListItemType.I t
em); di.Cells.Add(tc );
di.Cells.Add(tc 1);
Table t = (Table)DataGrid 1.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(Da taGrid1.Items.C ount+1,0,ListIt emType.Item);

--

Jos
Nov 18 '05 #3

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

Similar topics

4
5465
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 dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last...
2
3282
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 the selected lie item at which case I would pop up a separate dialog box to do so, in the debugging code, the dataview.count would return 0. I get...
3
4863
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 the best method? Do you have a sample of how to do this?
0
1865
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 collect the data in the Textboxes which i added dynamically from server side, i am not able to do . Alos i tried to bedug, the total no of rows in Html...
4
1818
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 with a buttonRow that does a delete function for me. Microsoft support helped me back then to get this done. Here is part of the code that creates...
0
1056
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 doing wrong. I'm using Visual Studio with SQL 2000. This is question/answer page that loads questions & answers dynamically. I would like to present 1...
0
1923
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 ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean Const WM_KEYDOWN As Integer = &H100
1
2580
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 cells - they are generated through the odswierz_frekfencje() function (listed below)-
12
6193
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 datagrid. Once I can get to that point I need some way to be able to add new data only to the new columns that were added. Here is some of my...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.