Link to home
Start Free TrialLog in
Avatar of mmeisel
mmeiselFlag for United States of America

asked on

Repeater Help

I have created a repeater that displays academic information (degrees, college, etc.).  I want the user to be able to edit the entry (entry = degree).  Right now I'm attempting to use a LinkButton and pass the EntryID as the CommandArguement.  I thought this would work but I'm getting a strange error(Unable to cast object of type 'System.EventArgs' to type 'System.Web.UI.WebControls.CommandEventArgs').

My questions:

1. Is the route I'm taking possible, if so what am I doing wrong?

2. What are your suggestions for using a repeater and passing a parameter?

Thanks.
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="odsDegreeDetails">
                <HeaderTemplate>
                    <table width="80%">
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td style="width: 60%; vertical-align: top">
                            <b>Institution: </b>
                            <%#Container.DataItem("NAME")%>
                        </td>
                        <td style="width: 40%; vertical-align: top">
                            <b>Degree: </b>
                            <%#Container.DataItem("DESCRIPTION")%>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 60%; vertical-align: top">
                            <b>Major: </b>
                            <%#Container.DataItem("MAJOR")%>
                        </td>
                        <td style="width: 40%; vertical-align: top">
                            <b>Grad. Date: </b>
                            <%#Container.DataItem("END_DATE")%>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <b>Honors:</b>
                            <%#Container.DataItem("HONOR")%>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:LinkButton ID="lbEdit" runat="server" CommandArgument='<%#Container.DataItem("DegreesId")%>'  ValidationGroup="Edit" OnClick="lbEdit_Click">Edit</asp:LinkButton>
                            | <a href="delete_degree.aspx?DegreesId=<%#Container.DataItem("DegreesId")%>" onclick="confirmDelete()">
                                Delete</a>
                        </td>
                    </tr>
                </ItemTemplate>
                <SeparatorTemplate>
                    <tr>
                        <td colspan="2">
                            &nbsp;
                        </td>
                    </tr>
                </SeparatorTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>

Open in new window

Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

Why don't u use the gridview. Editing a gridview is much easier I suppose
Avatar of mmeisel

ASKER

That's true but I want one record to span multiple rows.  For example (-> indicates the following column)

College 1 -> Degree 1
Major 2 -> Grad Date 1
Edit | Delete

College 2 -> Degree 2
Major 2 -> Grad Date 2
Edit | Delete

etc.

If there is a way to do this with a gridview then fantastic but I thought gridviews could only display one row for each record.
Try placing gridview inside the repeater and bind the gridviews....

Then it might be possible to edit the gridview inside the repeater....
Avatar of mmeisel

ASKER

CodeCruisier:

I'm not necessarily trying to edit the information in the repeater.  What I'm trying to accomplish is to pass the CommandArguement to the event handler, in this case lbEdit_Click.  With that CommandArguement I'm going to query the database and populate another form on the page.  My problem is that I cannot read the CommandArguement in the event handler (lbEdit_Click).
That is what i meant. What you can do is bind the Tag property of the Edit button to the DegreeID instead of using CommandArguments because repeater does  not use command arguments. Then on serverside, you can access the Tag property of the button easily.
ASKER CERTIFIED SOLUTION
Avatar of mmeisel
mmeisel
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial