如何在radiobutton更改时显示文本框..在datalist中 [英] How to visible textbox when radiobutton changed .. in datalist

查看:74
本文介绍了如何在radiobutton更改时显示文本框..在datalist中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:DataList ID="DataList_MainChoiceQuest" runat="server">
    <ItemTemplate>
        <div class="voting-item">
        	<h4>
                <asp:Label ID="Label_MainQuestion" runat="server" Text='<%# Eval("Question_Text") %>' ToolTip='<%# Eval("Question_ID") %>'></asp:Label> 
                ؟</h4>
        	<ul>
               <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
               <ContentTemplate>
               
              <a id="<%# Eval("SrNo") %>" onmouseover="FunctionIndex(this)" >
               
        	<li><asp:RadioButton ID="RadioButton1" runat="server" 

                    Text='<%# Eval("Option_Text") %>' GroupName="ch"  

                     /></li>
            <li><asp:RadioButton ID="RadioButton2" runat="server"  

                    Text='<%# Eval("Option2_Text") %>' GroupName="ch"  

                    /></li>
            <li><asp:RadioButton ID="RadioButton3" runat="server" 

                    Text='<%# Eval("Option3_Text") %>' GroupName="ch"   

                      /></li>
            <li>
           
            <asp:RadioButton ID="RadioButton4" runat="server" Text="أخري" GroupName="ch" 

          AutoPostBack="True" />
               </a>
                    </li>
            <li><%--<textarea name="" cols="" rows=""></textarea>--%>
                <asp:TextBox ID="TextBox_Other" runat="server" TextMode="MultiLine" Visible="False"></asp:TextBox>
            </li>
             </ContentTemplate>
               </asp:UpdatePanel>
        </ul>
        </div>
    </ItemTemplate>
    <FooterTemplate>
           
    </FooterTemplate>
</asp:DataList>

推荐答案

我没有复制你的整个场景,但我认为你应该这样做。



首先在你的RadioButtons中添加一个CheckedChanged事件,类似这样:



I did not replicate your whole scenario but here is what I think you should do.

First add a CheckedChanged event in your RadioButtons, something like this:

<ul><li><asp:radiobutton id="RadioButton1" runat="server" xmlns:asp="#unknown">
                    Text='<%# Eval("Option_Text") %>' GroupName="ch" AutoPostBack="true" OnCheckedChanged="RadioButton1_CheckedChanged"
                     /></asp:radiobutton></li></ul>



以下是您在该事件中可以执行的操作,以设置该TextBox的可见性在DataList中:


and here is what you can do inside that event to set the Visibility of that TextBox inside the DataList:

protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton radioBtn = sender as RadioButton;
            if (radioBtn != null)
            {
                DataListItem item = radioBtn.NamingContainer as DataListItem;
                if (item != null)
                {
                    TextBox txt = item.FindControl("TextBox_Other") as TextBox;
                    if (txt != null)
                    {
                        txt.Visible = true;
                    }
                }
            }

        }





希望有帮助



祝你好运



Azee ......



Hope it helps

Good luck

Azee...


这篇关于如何在radiobutton更改时显示文本框..在datalist中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆