<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="id" HeaderText="id"></asp:BoundColumn>
</Columns>
</asp:DataGrid>int b = dataGridView1.Rows.Count;
ArrayList al;
for (int i = 1; i < b; i++)
{
CheckBox cb = DataGrid1.Items[i].Cells[0].FindControl("CheckBox1") as CheckBox;
if (cb.Checked)
{
al.Add(DataGrid1.Items[i].Cells[1].Text);//记录id,方便构造insert语句
} }
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="id" HeaderText="id"></asp:BoundColumn>
</Columns>
</asp:DataGrid>int b = dataGridView1.Rows.Count;
ArrayList al;
for (int i = 1; i < b; i++)
{
CheckBox cb = DataGrid1.Items[i].Cells[0].FindControl("CheckBox1") as CheckBox;
if (cb.Checked)
{
al.Add(DataGrid1.Items[i].Cells[1].Text);//记录id,方便构造insert语句
} }
解决方案 »
- 有[Ajax.AjaxMethod()]的方法获取不到页面控件的值
- 请大家帮我写一个插入数据函数
- firefox中,无法解决按下回车键刷新的问题
- inetinfo.exe快把我给搞疯了!!!!求救啊!!!
- 向存储过程中传入一xml格式的文档,用转义字符处理双引号后,存储过程不能转过来?
- 请教自动登陆网页的winform程序,高分!
- 如何用asp.net在excel文件中将数据按需填入事先做好的表格中去?并生成一个新的excel文件!
- swfupload asp.net使用
- 怎么样把一个datatable数据写成一个xml文件了?
- 急求c#中的权限更改代码,200相送!!!!!!
- 发现一个英文高清pdf下载网站
- Web程序中怎样弹出一个浮动窗体
for (int i = 0; i < b; i++)
{
if ((bool)dataGridView1.Rows[i].Cells[0].Value)
x++;
}
int x = 0;
for (int i = 0; i < b-1; i++)
{
if ((bool)(dataGridView1.Rows [i].Cells [0].Value)) 这一句 提示未将对象应用到实例 (大体意思)
x = x + 1; }
MessageBox.Show(x.ToString ());
}
这样不对。
提示未将对象应用到实例 (大体意思)
{
for (int i = 0; i < DataList1.Items.Count; i++)
{
CheckBox cbSingle = (CheckBox)DataList1.Items[i].FindControl("CheckBoxSingle");
if (cbSingle.Checked == true)
{
string ID = DataList1.DataKeys[i].ToString();
Response.Write("<br />"+ID);
}
} }
foreach(GridViewRow i in GridView1.SelectedRow)
{
num++;
}