行编辑事件后,GridView中的单选按钮列表 [英] Radiobuttonlist in gridview after rowediting event

查看:49
本文介绍了行编辑事件后,GridView中的单选按钮列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在gridview中使用单选按钮列表和文本框.我需要对radiobuttonlist进行操作,以便它可以反映在textbox上.这是在gridview_rowediting事件触发后完成的,即当我们可以看到更新"和取消"按钮时.我这样尝试过,

 受保护的 无效 GridView1_RowEditing(对象发​​件人,GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;

        GridViewRow editingRow = GridView1.Rows [e.NewEditIndex];

        RadioButtonList rbl =(RadioButtonList)editingRow.Cells [ 17 ].FindControl(" );
        rbl.Visible =  true ;
        TextBox txtamt =(TextBox)editingRow.Cells [ 18 ].FindControl(" );
        txtamt.Enabled =  true ;
         
            如果(rbl.SelectedItem.Value.Contains(" ))
            {
                txtamt.Enabled =  true ;
            }
            其他 如果(rbl.SelectedItem.Value == "  2")
            {
                txtamt.Enabled =  true ;
            }
            其他 如果(rbl.SelectedItem.Value == "  0")
            {
                txtamt.Enabled =  false ;
            }
       
    } 


这里默认选择的值是源中给出的"0".

我的问题是,当我更改所选项目时,相应的操作未完成.

如果未在rowediting事件中执行此操作,请给我适当的解决方案.

解决方案

在"onClick"事件中对该类型的操作使用Java脚本.

< asp:RadioButtonList AutoPostBack = true runat =服务器ID = RadioButtonList/>

您需要检查是否包含AutoPostBack = true.


Hi,

I am using radiobuttonlist and textbox in the gridview. I need to do operations on radiobuttonlist so that it should reflect on textbox . this is to be done after gridview_rowediting event fires i.e when we can see "update" and "cancel" buttons. I tried like this,

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;

        GridViewRow editingRow = GridView1.Rows[e.NewEditIndex];

        RadioButtonList rbl = (RadioButtonList)editingRow.Cells[17].FindControl("rblist11");
        rbl.Visible = true;
        TextBox txtamt = (TextBox)editingRow.Cells[18].FindControl("TextBox3");
        txtamt.Enabled = true;
         
            if (rbl.SelectedItem.Value.Contains("1"))
            {
                txtamt.Enabled = true;
            }
            else if (rbl.SelectedItem.Value == "2")
            {
                txtamt.Enabled = true;
            }
            else if (rbl.SelectedItem.Value == "0")
            {
                txtamt.Enabled = false;
            }
       
    }


Here default selected value is "0" given in source.

My problem here is when I am changing the selecteditem, the corresponding action is not done.

if this action is not done in rowediting event, Please give me the appropriate solution.

解决方案

Use java script for this type operation on "onClick" event.


<asp:RadioButtonList AutoPostBack=true runat=server ID=RadioButtonList />

you need check AutoPostBack=true whether in it.


这篇关于行编辑事件后,GridView中的单选按钮列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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