问题描述
您好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
推荐答案
<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>
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.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!