문제

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.

도움이 되었습니까?

해결책

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%>'

다른 팁

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)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top