主题:急急急!!实例!DATAGRID怎么转GRIDVIEW
DATAGRID
foreach (DataGridItem item in VoteList.Items)
{
CheckBox check = (CheckBox)item.FindControl("VoteCheck");
if (check != null)
{
if (check.Checked == true)
{
vote.UpdateVote(Int32.Parse(VoteList.DataKeys[item.ItemIndex].ToString()));
}
}
}
怎么转GRIDVIEW?下面我是这样写的
foreach (GridViewRow g in GridView1.Rows)
{
CheckBox check = (CheckBox)g.FindControl("VoteCheck");
if (check != null)
{
if (check.Checked)
{
SQLHelper helper = new SQLHelper();
VoteItems v = new VoteItems();
v.Update(helper.mycon,Int32.Parse(GridView1.DataKeys[g.RowIndex].ToString()));/*这句话抱错,索引超出范围。必须为非负值并小于集合大小。参数名: index 报这个错*/
}
}
}
foreach (DataGridItem item in VoteList.Items)
{
CheckBox check = (CheckBox)item.FindControl("VoteCheck");
if (check != null)
{
if (check.Checked == true)
{
vote.UpdateVote(Int32.Parse(VoteList.DataKeys[item.ItemIndex].ToString()));
}
}
}
怎么转GRIDVIEW?下面我是这样写的
foreach (GridViewRow g in GridView1.Rows)
{
CheckBox check = (CheckBox)g.FindControl("VoteCheck");
if (check != null)
{
if (check.Checked)
{
SQLHelper helper = new SQLHelper();
VoteItems v = new VoteItems();
v.Update(helper.mycon,Int32.Parse(GridView1.DataKeys[g.RowIndex].ToString()));/*这句话抱错,索引超出范围。必须为非负值并小于集合大小。参数名: index 报这个错*/
}
}
}