protected  void  Index_Changed(object  sender,  System.EventArgs  e)不行,用public 。

解决方案 »

  1.   

    事件可以引发了,是我没把MyGrid();放在if(!Page.IsPostBack)里的缘故, 每次刷新有梆定数据了,现在有新的问题,出现"引超出范围。必须为非负值并小于集合大小。参数名:index "错误.
        出错代码为下面一这行
      flag=(RadioButtonList)DataGrid1.Items[3].FindControl("complain_flag");请问该如何解决。
      

  2.   

    flag=(RadioButtonList)DataGrid1.Items[4].FindControl("complain_flag");
    应该是这样,但错误还是一样
      

  3.   

    RadioButtonList flag=(RadioButtonList)DataGrid1.Items[4].FindControl("complain_flag");这儿的Item[4]是指第4行,不是第4列
      

  4.   

    for( int i = 0; i < DataGrid1.Items.Count; i ++ )
    { RadioButtonList ra=(RadioButtonList)DataGrid1.Items[i].FindControl("RadioButtonList1");
    if(ra!=null)
    {
                                }
    }
      

  5.   

    多谢,但现在还是在数据库里更改不了complain_flag的值,可能是因为无法确定keywords,我将这部分代码全部贴出来你看看错在哪里
      public void Index_Changed(object sender, System.EventArgs e) 
     {

     for( int i = 0; i < DataGrid1.Items.Count; i ++ )
      {   RadioButtonList ra=(RadioButtonList)DataGrid1.Items[i].FindControl("RadioButtonList1");
        string complain= DataGrid1.Items[i].Cells[5].Text;
     
     Response.Write("<script>alert('complain');</script>");
      if(ra!=null)
      {

      string updateCmd = "update complain_info set comlain_flag=@complain_flag where complain_id=@complain_id";   SqlCommand myCommand = new SqlCommand(updateCmd,sqlConnection1);   myCommand.Parameters.Add(new SqlParameter("@complain_flag", SqlDbType.VarChar, 50));     myCommand.Parameters["@complain_flag"].Value =ra.SelectedItem.Value;   myCommand.Parameters.Add(new SqlParameter("@complain_id", SqlDbType.Int, 11));   myCommand.Parameters["@complain_id"].Value =Convert.ToInt32(complain);   sqlConnection1.Open();   myCommand.ExecuteNonQuery();   Response.Write("<script>alert('你已更改记录');</script>");   sqlConnection1.Close();   MyGrid();              
      }//end if   }//end for
    }