473,387 Members | 1,705 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,387 software developers and data experts.

Add New Row to DataGrid or Repeater

I am working on a web form that allows the user to add a new row.
Basically I query the data from a database and store it in a dataset.
I add a new row to the table in the dataset:

DataRow dr = objDataSet.Tables[0].NewRow();
objDataSet.Tables[0].Rows.Add(dr);

When I bind the data to a datagrid I see the blank row. When I bind
the data to my repeater, I don't see the blank row. Any ideas why?

Here is the html
<table border=3>
<ASP:Repeater id="MyRepeater" runat="server">
<HeaderTemplate>

<tr bgcolor="#BDC0C7">
<td width="16%" class="ary_header">Title</td>
<td width="16%" class="ary_header">ISBN</td>
<td width="16%" class="ary_header">Publication Date</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bordercolor=#006600>
<td class="alignC"><%# DataBinder.Eval(Container.DataItem, "Title")
%></td>
<td class="alignC"><%# DataBinder.Eval(Container.DataItem, "ISBN")
%></td>
<td class="alignC"><%# DataBinder.Eval(Container.DataItem,
"PublicationDate", "{0:D}") %></td>
</tr>
</ItemTemplate>
</ASP:Repeater>
</table>

Nov 19 '05 #1
2 8437
Do u bind repeater after adding row ? I think you specify the source for the
repeater from codebehind. Because there is no DataSource property in the
code you gave.

--
Thanks,
Yunus Emre ALPÖZEN

<rw*****@yahoo.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I am working on a web form that allows the user to add a new row.
Basically I query the data from a database and store it in a dataset.
I add a new row to the table in the dataset:

DataRow dr = objDataSet.Tables[0].NewRow();
objDataSet.Tables[0].Rows.Add(dr);

When I bind the data to a datagrid I see the blank row. When I bind
the data to my repeater, I don't see the blank row. Any ideas why?

Here is the html
<table border=3>
<ASP:Repeater id="MyRepeater" runat="server">
<HeaderTemplate>

<tr bgcolor="#BDC0C7">
<td width="16%" class="ary_header">Title</td>
<td width="16%" class="ary_header">ISBN</td>
<td width="16%" class="ary_header">Publication Date</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bordercolor=#006600>
<td class="alignC"><%# DataBinder.Eval(Container.DataItem, "Title")
%></td>
<td class="alignC"><%# DataBinder.Eval(Container.DataItem, "ISBN")
%></td>
<td class="alignC"><%# DataBinder.Eval(Container.DataItem,
"PublicationDate", "{0:D}") %></td>
</tr>
</ItemTemplate>
</ASP:Repeater>
</table>

Nov 19 '05 #2
When you run the page and view the source html of it, does the datagrid
insert &nbsp; into the fields of the new row? If so, the repeater may
not display the new row because content of each data item is not
automatically generated so you basically have an empty
row<TR><TD></TD></TR>) which won't display unless there is some content
forcing it to display. Even an empty string might force it to be
displayed.

Nov 19 '05 #3

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

Similar topics

3
by: Jeremy Ames | last post by:
I am trying to use a datagrid to pull information from a database. I prefer to use latebinding to this. Well, I finally got my information to populate the datagrid, but the information came out in...
2
by: Stephen Miller | last post by:
I am using the OnItemDataBound event of Repeater control to nest a DataGrid within the Repeater. When I attempt to bind to the DataGrid using the DataSource method I get the error message "Object...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
7
by: Scott Schluer | last post by:
Hi All, I have a functioning datagrid on "Page 1" that displays order information for a single order (this is for an e-commerce site). It's actually a combination of a couple datagrids to...
2
by: News | last post by:
Hi I need help to display and edit data in a data grid within a repeater. The code is below: Sub dgrdEvents_EditCommand(sender As Object, e As DataGridCommandEventArgs)...
0
by: Ferret | last post by:
I've found what seems to be a nasty bug in the DataGrid and Repeater classes. If CreateChildControls gets called before LoadViewState, ViewState fails to map and you end up with nothing on a...
3
by: Maziar Aflatoun | last post by:
Hi everyone, I have a datagrid that I create inside a Repeater at runtime. I have defined a checkbox beside each row so that users can select multiple rows. <asp:datagrid id="dgProducts"...
1
by: JD | last post by:
Hello Everyone, I am trying to do a page where when the user gets to the page it will look very similar to the following: <table border=1> <tr> <td bgcolor="green" colspan="2">Main...
4
by: voidfill3d | last post by:
I do not know if this is possible with a datagrid or a repeater or some other object, but I am looking to create a report via a table like structure similar to that of a report you would create in...
2
by: mark4asp | last post by:
This page is currently using a Repeater control to create a table with 6 columns. The first column has 2 ImageButton controls and a common header. How can I do this with a DataGrid ? I need...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...

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.