Nethra R S

Nethra R S

  • NA
  • 310
  • 334.3k

Want to access cell value in a gridview at selected indexchanged event

Jun 28 2011 5:18 AM
Hi,

Here is the code:

protected void gvProjectDetails_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        string proj_id = gvProjectDetails.SelectedRow.Cells[1].Text;
        conobj.connect();
        conobj.CMD.CommandText = "select * from ProjectDetailsMaster where ProjectID='"+proj_id+"'";
        conobj.DTR = conobj.CMD.ExecuteReader(CommandBehavior.CloseConnection);
       
        while (conobj.DTR.Read())
        {
            txtprojname.Text=conobj.DTR["ProjectName"].ToString();
            txtprojdescription.Text = conobj.DTR["Description"].ToString();
            txtstartdate.Text = conobj.DTR["StartDate"].ToString();
            txtenddate.Text = conobj.DTR["EndDate"].ToString();
            txtduration.Text = conobj.DTR["Duration"].ToString();
        }
            conobj.DTR.Close();
    }

=================================================
Getting an error: Object reference not set to an object at the 1st line of code

Answers (2)