1

I have the following repeater code:

 <asp:Repeater ID="repMain" runat="server" OnItemCommand="repMain_ItemCommand" EnableViewState="false">
    <ItemTemplate>
    <dmg:testcontrol runat="server" MyData=<%#Container.DataItem %>>


    </dmg:testcontrol>
    </ItemTemplate>
    </asp:Repeater>

The testcontrol usercontrol looks like:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestControl.ascx.cs" Inherits="TestRepeater.TestControl" %>
<asp:Literal runat="server" ID="litMain" Text="<%#MyData.MyValue %>"></asp:Literal>
<asp:DropDownList runat="server" ID="dropdownMain"></asp:DropDownList>
<asp:Button runat="server" ID="btnMain" Text="Click Me" CommandName="Update" CommandArgument="<%#dropdownMain.SelectedValue%>"/>

Is it possible for me to send through the dropdownMain.SelectedValue as the CommandArgument?

Just now it is an empty string.

Thanks

Duncan

PS This is related to ASP.NET Repeater not binding after ItemCommand but I thought the two sufficiently different to keep apart.

2 Answers 2

2

A bit old question but I just my self found the answer to this one.

CommandArgument="<%#dropdownMain.SelectedValue%>"

Needs to look like this instead with single quotes! All inline codes within a asp.net controls have to be done this way instead.

CommandArgument='<%#dropdownMain.SelectedValue%>'
Sign up to request clarification or add additional context in comments.

Comments

0

Why not get the selected value, and use it inside the Command function ?

(why to try to send it as argument, from the moment you can get it inside the command called function and its the same)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.