c# - 如何从同一中继器项目中的下拉列表中选择的更改事件中获取中继器项目中控件的值?

标签 c# asp.net repeater

<ItemTemplate>
   <tr class="odd gradeX">
      <td>
         <%#Eval("Caption")%>
      </td>
      <td>
         <%#Eval("CreatedBy")%>
      </td>
      <td>
         <%#Eval("CreationDate")%>
      </td>
      <td>
         <%#Eval("Status")%>
      </td>
      <td class="center">
         <div class="controls center">
            <a href="NewsCommentEdit.aspx?mtid =<%#Eval("UserId")%>" title="Güncelle" class="tip">
               <span class="icon12 icomoon-icon-pencil"></span>
            </a>
         </div>
      </td>
      <td>
         <asp:HiddenField runat="server" ID="hdnComment" Value='<%#Eval("NewsCommentId")%>' />
         <asp:DropDownList runat="server" ID="ddlStatus" AutoPostBack="True"  OnSelectedIndexChanged="ddlStatus_Changed">
            <asp:ListItem Text="Onay Bekliyor" Value="0"></asp:ListItem>
            <asp:ListItem Text="Onaylandı" Value="1"></asp:ListItem>
            <asp:ListItem Text="Reddedildi" Value="2"></asp:ListItem>
         </asp:DropDownList>
      </td>
   </tr>
</ItemTemplate>

我想在ddlStatus的选定索引更改事件中获取hdnComment的值。这可能吗?如何实现?

最佳答案

    protected void ddlStatus_Changed(object sender, EventArgs e) 
    {
        string value;
        HiddenField comment = ((Control)sender).Parent.FindControl("hdnComment") as HiddenField;
        if (comment != null) 
        {
            value = comment.Value;
        }
    } 

关于c# - 如何从同一中继器项目中的下拉列表中选择的更改事件中获取中继器项目中控件的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15159062/

相关文章:

c# - 装箱值类型以将其发送到方法并获取结果

c# - 对 Request.Files 的 foreach

c# - 中继器的 ItemDataBound 不会影响某些值

asp.net - asp.net 中继器中的服务器控件

ASP.NET Gridview - 从代码后面设置列标题的 css 类?

c# - 在 Repeater 控件中找不到标签控件

c# - 如何使用 PictureBox 打开/关闭相机

c# - 如何在 C# 中有条件地执行 Fluent Migrator 脚本

c# - 通用图像类型 emgu C#

C#并行循环局部变量线程安全资料