Help with repeater and datagrid

N

News

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"
<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
 
N

News

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

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

Similar Threads

repeater 0
Problem with Data Grid 0
Error referencing Datagrid table cell 3
dropdownlist in datagrid 1
Nested Repeater within Grid 0
What is wrong with my DataGrid? 1
ASP.NET Datagrid 1
DropDownList DataGrid 1

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top