i m getting an error(Input string was not in a correct format.) on click of detail button please help me to resolve this problem.
my code is
protected void grdexam_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "dtls")
{
Button btn = (Button)e.CommandSource;
var index =Convert.ToInt32(btn.CommandArgument.ToString());
GridViewRow row = grdexam.Rows[index];
Label l1 = (Label)row.FindControl("Label1");
SqlCommand cmd = new SqlCommand("select * from ExamMaster where groupid='" + Session["grpid"] + "' and papercode='" + l1 + "'", con);
SqlDataAdapter adp = new SqlDataAdapter();
DataTable dt = new DataTable();
adp.Fill(dt);
if (dt.Rows.Count > 0)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
else
{
Response.Write("wromg");
}
}
}
please help me
thanks in advance

Ajay Saini125 reputationPosted Sep 28, 2013, 8:55 AM EDT
actually you have using incorrect idea to find row index, use it as :
int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = grdexam.Rows[index]; use itGopal Ji Singh39 reputationPosted Sep 30, 2013, 1:01 AM EDT
if i would like to use multiple row index value from gridview in row command then what i should use.
for example i want to store
name and subject in session on row command then what would i use. please tell me