日期:2014-05-18  浏览次数:20502 次

DataReader求救问题,请各位大侠帮忙。
SqlConnection   con   =   Class1.lj();
                                SqlCommand   cm   =   new   SqlCommand( "select   *   from   xg ",   con);
                                SqlDataReader   red   =   cm.ExecuteReader();
                                red.Read();
                                string[]   sd   =   new   string[2];
                                sd[0]   =   red.IsDBNull(0)   ?   " "   :   red.GetValue(0).ToString();
                                sd[1]   =   red.IsDBNull(1)   ?   " "   :   red.GetValue(1).ToString();
                                for   (int   i   =   0;   i   <   this.GridView1.Rows.Count;   i++)
                                {
                                 
                                        string   bh   =   " ";
                                        string   sj   =   " ";
                                        bh   =   ((Label)this.GridView1.Rows[i].Cells[0].FindControl( "lbl1 ")).Text;
                                        sj   =   ((Label)this.GridView1.Rows[i].Cells[5].FindControl( "lbl5 ")).Text;
                                        if   (bh   ==   sd[0].ToString()   &&   sj   ==   sd[1].ToString())
                                        {
                                                this.GridView1.Rows[i].Cells[3].ForeColor   =   Color.LimeGreen;
                                        }
                                }