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
Want to access cell value in a gridview at selected indexchanged event
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Morcos Adel115 reputationPosted Jun 28, 2011, 1:37 AM EDT
i think you should use the event
GridView1_SelectedIndexChanged(object sender, EventArgs e)
not _SelectedIndexChanging
hope this helps :)
Nethra R SRank #6,347 · 269 reputationPosted Jun 28, 2011, 1:39 AM EDT