如果我选中复选框数据应该显示 [英] if i check Checkbox data should display

查看:82
本文介绍了如果我选中复选框数据应该显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4个复选框,已应用",已批准",已拒绝",已取消".
如果我选中已应用复选框,我想显示Apply_table数据,怎么办?有了一些主意.

在gridview或表中的任何解决方案,请.......

i have 4 checkboxes, Applied, Approved, Rejected, Cancelled.
if i check on applied checkbox i want to display Apply_table data, how? gve some idea.

in gridview or table any solution pls.....

推荐答案

<asp:CheckBoxList ID="chklist" runat="server" AutoPostBack="True" OnSelectedIndexChanged="chklist_SelectedIndexChanged"

                                                                            RepeatDirection="Horizontal">
                                                                            <asp:ListItem Value="0">Applied </asp:ListItem>
<asp:ListItem Value="1">Approved </asp:ListItem>
<asp:ListItem Value="2"> Rejected</asp:ListItem>                                                  <asp:ListItem Value="3">Cancelled</asp:ListItem>
                                                                        </asp:CheckBoxList>











protected void chklist_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            
            if (chklDispencelist.Items[0].Selected == true)
            {
                //get data from applied table

            }
            if (chklDispencelist.Items[1].Selected == true)
            {
                //get data from approved table

            }
            if (chklDispencelist.Items[2].Selected == true)
            {
               //get data from Rejectedtable

            }
            if (chklDispencelist.Items[3].Selected == true)
            {
                
               //get data from Cancelledtable
            }
        }
        catch ()
        {
            Response.write(ex);
        }
    }






如果您对复选框列表不感兴趣,则可以使用单个复选框
并在相应复选框的checkedchanged事件中,可以为相应的表数据编写代码






if you are not interested in checkbox list you can use individual checkboxes
and in checkedchanged event of respective checkbox you can write your code for respective table data


尝试将具有这些选项的复选框列表用作列表项,并使用autopostback true为该列表注册checkchanged事件.

然后,在事件中,基于已将所选属性设置为true的项目从数据库中获取数据,并将其绑定到gridview
Try to use a checkbox list with these options as list item and register checkchanged event for this list with autopostback true.

Then in the event get the data from database based on the items having selected property set as true and bind them to gridview


set
autopostback="true"

到应用的复选框

在oncheckedchanged事件中,编写以下内容

to applied checkbox

In oncheckedchanged event write as follows

OnCheckedChanged event()
{
  if(chkapplied.checked)
  {
    //get record and bind to grid;
  }
  else
  {
    // make grid visible false
    //or bind empty table to grid
  }
}


这篇关于如果我选中复选框数据应该显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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