binding the data in the gridview

Jan 13 2009 6:55 AM

Hi,

 

i am binding the data in the gridview as below;

 

protected void btnget_Click(object sender, EventArgs e)

{

lblerror.Text = "";

pnlmynomn.Visible = true;

grdawarddet.Visible = true;

pnlAOQ.Visible = false;

SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettings["ConnString"].ToString());

SqlCommand cmd = new SqlCommand();

SqlDataAdapter da = new SqlDataAdapter();

DataSet ds = new DataSet();

CultureInfo ci = new CultureInfo("en-GB", true);

try

{

int optionVal = 1;

conn = new SqlConnection();

conn.ConnectionString = connstr;

cmd = new SqlCommand();

cmd.Connection = conn;

conn.Open();

cmd.Connection = sqlconn;

cmd.CommandType = CommandType.StoredProcedure;

cmd.CommandText = "HRN_NominationRep";

cmd.Parameters.AddWithValue("@year", drphryears.SelectedItem.ToString());

cmd.Parameters.AddWithValue("@quarter", drphrqtr.SelectedItem.ToString());

cmd.Parameters.AddWithValue("@optionVal", drphroption.SelectedItem.ToString());

cmd.Parameters.AddWithValue("@nominatedby", username);

da.SelectCommand = cmd;

da.Fill(ds, "MyNominations");

if (optionVal == '2')

{

grdawarddet.DataSource = ds.Tables[0];

grdawarddet.DataBind();

grdawarddet.Visible = true;

}

else if (optionVal == '1')

{

grdawarddet.DataSource = ds.Tables[0];

grdawarddet.DataBind();

grdawarddet.Visible = true;

}

else

{

optionVal = 0;

grdawarddet.DataSource = ds.Tables[0];

grdawarddet.DataBind();

grdawarddet.Visible = true;

}

}

catch (Exception ex)

{

lblerror.Text = ex.Message;

lblerror.Visible = true;

}

finally

{

conn.Close();

}

}

 

but the error is  coming while running the project.  please help me in this.

 

Thanks in advance,

Geetha


Answers (1)