Sun_china

交流更多,收获更多?

博客园 首页 新随笔 联系 订阅 管理

1:datagrid 

string strSomeId="";
   for(int index=0;index<dataGrid.Items.Count;index++)
   {
    if(this.dataGrid.Items[index].ItemType==ListItemType.AlternatingItem || this.dataGrid.Items[index].ItemType==ListItemType.Item)
    {
     CheckBox check=(CheckBox)this.dataGrid.Items[index].FindControl("check");
     if(check.Checked)
     {
      strSomeId+=this.dataGrid.DataKeys[index]+",";
     }
    }
    else
    {
     continue;
    }

   }
   return strSomeId.TrimEnd(',');

 

2:gridview

 string pAllID = null;

        foreach (GridViewRow gvRow in gvCopyright.Rows)
        {
            CheckBox check = (CheckBox)gvRow.FindControl("check");

            if (check.Checked)
            {
                pAllID += gvCopyright.DataKeys[gvRow.RowIndex].Value.ToString() + ",";
            }
            else
            {
                continue;
            }
        }

        return pAllID.TrimEnd(',');

posted on 2008-09-03 08:54  Sun_china  阅读(536)  评论(0编辑  收藏  举报