当前位置: 代码迷 >> ASP.NET >> DataReader求救有关问题,请各位大侠帮忙
  详细解决方案

DataReader求救有关问题,请各位大侠帮忙

热度:5506   发布时间:2013-02-25 00:00:00.0
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;
                                        }
                                }
                                con.Close();
                                red.Close();