470,596 Members | 1,594 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

Help with repeater and datagrid

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)
dgrdEvents.EditItemIndex = e.Item.ItemIndex
BuildList()
End Sub
<asp:Repeater ID="rptEvents" RunAt="server">
<ItemTemplate>
<p><strong><%# Container.DataItem("summary") %></strong>
<asp:DataGrid id="dgrdEvents" Width="500" BorderWidth="0" CellPadding="3"
CellSpacing="0" DataKeyField="event_id"
DataSource='<%# FilterEvents( Container.DataItem("event_id") ) %>
OnEditCommand="dgrdEvents_EditCommand"

<Columns>
<asp:BoundColumn Visible="False" HeaderText="" DataField="eventdate_id"
SortExpression="eventdate_id" />
<asp:TemplateColumn HeaderText="Start Date">
<ItemTemplate>
<asp:label Text='<%# Container.DataItem("start_date") %>' runat="server"
/>
</ItemTemplate>
<EditItemTemplate>
<asp:Textbox id="txtStartdate" Columns="8" Text='<%#
Container.DataItem("start_date") %>' runat="server" />
</EditItemTemplate>
<ItemTemplate>
<asp:label Text='<%# Container.DataItem("end_date") %>' runat="server"
/>
</ItemTemplate>
<EditItemTemplate>
<asp:Textbox id="txtEnddate" Columns="8" Text='<%#
Container.DataItem("end_date") %>' runat="server" />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn EditText="Edit" UpdateText="Save"
CancelText="Cancel" />
</Columns>
</asp:DataGrid>
</ItemTemplate>
</asp:Repeater>
Clicking on the Edit link should open an item (eg. start date) of the data
grid for editing. I am getting this error:
"Name 'dgrdEvents' is not declared
.....
Line 109: dgrdEvents.EditItemIndex = e.Item.ItemIndex".

If datagrid is not in a repeater the code above works fine. I understand
that because of the nature of a repeater the id of given data grid is not
known and I cannot set it statically. So my quesiton is how can I open a
given row in a grid for editing, given that this grid resides inside of a
repeater.
Thank you
Nov 18 '05 #1
2 1663
dump the repeater and use a datalist
Nov 18 '05 #2
This is not my app and I cant really make these kind of changes, at the end
if there is no alternative I would have to, but I think there should be a
way. Unfortunately, I am a novice and have to learn as I go...
"Josh" <so*****@microsoft.com> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
dump the repeater and use a datalist

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Stephen Miller | last post: by
2 posts views Thread by Daniel | last post: by
7 posts views Thread by Scott Schluer | last post: by
1 post views Thread by Ryan Ternier | last post: by
2 posts views Thread by Ceema M via DotNetMonster.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.