不会触发Gridview内部的CheckBox. [英] CheckBox Inside Gridview is not fired..

查看:68
本文介绍了不会触发Gridview内部的CheckBox.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好evryone ...
我有问题,我正在使用gridview内的复选框.我已应用"OnCheckedChanged ="Changed";在gridview中..当我单击复选框时,不会触发此事件...我在asp:checkbox ..中写入了autopostback = true,并且将自动事件联结"设置为"true".也写在页面顶部..但我无法找出未触发的原因..我正在此事件上使用此代码..pls帮助我..提前感谢...代码是在这里..

Hello evryone...
i have problem that i am using checkbox inside gridview..i have applied "OnCheckedChanged="Changed""; inside gridview..when i click on checkbox,this event is not fired...i have written autopostback=true inside asp:checkbox..and "auto event wireup" is set "true". is also written on top of page..but i am not able to find out the reason why it is not fired..i am using this code on this event..pls help me out..thanks in advance...code is here..

ArrayList userdetails = new ArrayList();
        int qidInt = 0;
       //Response.Write(DateTime.Now.ToLongTimeString());
       CheckBox checkBox = sender as CheckBox;
       string qid = checkBox.Attributes["id"];
       bool result = false;
       if (checkBox.Checked == true)
       {
            qidInt = Convert.ToInt32(qid);
           result = true;
       }
               if (result)
           {
               if (!userdetails.Contains(qidInt))
                   userdetails.Add(qid);
           }
           else
                   userdetails.Remove(qidInt);

   }


请帮帮我..我也尝试过在Google上搜索.我是开发领域的新手..pls帮助我帮忙..thnx


pls help me out..i have tried and search on google also.i am new in development field..pls help me out..thnx

推荐答案


检查您的aspx代码是否对我来说很好,如下所示

Hi
Check whether your aspx code looks like as follows as it is working finefor me

<asp:GridView ID="GridView1" runat="server" CssClass="grid" DataSourceID="SqlDataSource1"

        Height="124px" Width="974px" CellPadding="0" CellSpacing="0">
        <RowStyle CssClass="row" />
        <AlternatingRowStyle CssClass="altrow" />
        <Columns>
        <asp:TemplateField ItemStyle-CssClass="rownum" HeaderText="Delete">
                    <ItemTemplate>
                       <asp:CheckBox ID="cboxTest" runat="server" AutoPostBack="true"

                            oncheckedchanged="cboxTest_CheckedChanged" />
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" Width="10%" />
                </asp:TemplateField>
        </Columns>
    </asp:GridView>


在Gridview中将CommandName赋予Chechbox.说" Check1 "

您必须在gridview的RowCommand事件上执行代码.检查以下示例
Give CommandName to Chechbox in gridview. say "Check1"

You have to do the code on RowCommand event of gridview. check following example
void ProductsGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
 {
   // CommandName property to determine which button was clicked.
   if(e.CommandName=="check1")
   {
     // code on checkbox select 
   }
}


这篇关于不会触发Gridview内部的CheckBox.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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