Add New Row to DataGrid or Repeater

R

rwoo_98

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>
 
Y

Yunus Emre ALPÖZEN

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.
 
C

Corey

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top