RowDataBound DataKeys

    //给组织结构赋值
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    
{
        
if (e.Row.RowType == DataControlRowType.DataRow)
        
{
            
int userRegisterID = Convert.ToInt32(GridView1.DataKeys[e.Row.RowIndex].Value);
            CheckBoxList CheckBoxList1 
= (CheckBoxList)e.Row.Cells[6].FindControl("CheckBoxList1");

            DataTable dt 
= UserOrganization.sGetUserOrganizationByUserRegisterID(userRegisterID);

            
if (dt.Rows.Count != 0)
            
{
                
foreach (DataRow dtRow in dt.Rows)
                
{
                    
foreach (ListItem item in CheckBoxList1.Items)
                    
{
                        
if (Convert.ToInt32(item.Value) == Convert.ToInt32(dtRow["OrganizationID"]))
                        
{
                            item.Selected 
= true;
                        }

                    }

                }

            }

        }

    }
posted @ 2008-01-13 20:47  Fernando  阅读(805)  评论(0编辑  收藏  举报