返回首页

您好evryone ...
 60; 我有问题,我使用GridView的复选框内......我已申请"OnCheckedChanged ="更改"里面的GridView ......当我点击复选框,此事件不会触发...我写了里面ASP的AutoPostBack = TRUE:复选框......"汽车事件wireup的"设置"真"。页上还写......但我不能够找出为什么它没有被解雇......我使用此代码对这一事件的原因......请帮我提前感谢......代码这里..
&# 160;

 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);

      

    }
请帮助我......我曾试图和搜索谷歌also.i上午在发展领域的新..请帮我...... thnx

回答

评论会员:sriman.ch 时间:2012/02/07


检查是否你的aspx代码看起来像下面,因为它是我的工作finefor

<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>
评论会员:游客 时间:2012/02/07
koolprasad2003:给的CommandName在GridViewChechbox。说"CHECK1"的你必须做的代码,在GridView的RowCommand事件。检查下面的例子codeprelang="cs"spanclass="code-keyword"void/spanProductsGridView_RowCommand(spanclass="code-SDKkeyword"Object/spansender,GridViewCommandEventArgse){spanclass="code-comment"///spanspanclass="code-comment"CommandNamepropertytodeterminewhichbuttonwasclicked./spanspanclass="code-keyword"if/span(e.CommandName==spanclass="code-string""/spanspanclass="code-string"check1"/span){spanclass="code-comment"///spanspanclass="code-comment"codeoncheckboxselect/span}}/pre/code的