i use a repeater instead of grid view .In button i done with code but when i debug it shows me error....and i am trying approving documents but error occur
ok now i posted the whole code,,
protected void Button1_Click(object sender, EventArgs e)
{
string connStr = ConfigurationManager.ConnectionStrings["mydms"].ConnectionString;
SqlConnection mySQLconnection = new SqlConnection(connStr);
if (mySQLconnection.State == ConnectionState.Closed)
{
mySQLconnection.Open();
for (int i = 0; i < Repeater2.Items.Count; i++)
{
DropDownList DropDownListcontrol =
((DropDownList)Repeater2.Items[i].FindControl("DropDownList4"));
Label DocId = ((Label)Repeater2.Items[i].FindControl("DocId"));
SqlCommand cmd = new SqlCommand("approveddd", mySQLconnection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@DocID", SqlDbType.Int).Value =
Convert.ToInt32((DocId.Text));
cmd.Parameters.Add("@ApproveID", SqlDbType.Int).Value =
Convert.ToInt32(DropDownListcontrol.SelectedValue);
cmd.Parameters.Add("@ApproveBy", SqlDbType.VarChar, 50).Value =
(Session["Login2"]);
cmd.ExecuteNonQuery();
//UPDATE APPPROVEID IN DOCUMENTINFO TABLE
DMSLIB.Doc myDoc = new DMSLIB.Doc();
myDoc.MarkDocAs(Convert.ToInt16(DocId.Text),
Convert.ToInt32(DropDownListcontrol.SelectedValue));
}
}
else
{
apfi.Text = "Error";
}
if (mySQLconnection.State == ConnectionState.Open)
{
mySQLconnection.Close();
}
}
error in this line
cmd.Parameters.Add("@DocID", SqlDbType.Int).Value =
Convert.ToInt32((DocId.Text));
any idea?
ERROR: INPUT STRING WAS NOT IN CORRECT FORMAT
DocId.Textcontains a number? An empty value, for instance, will generate an error.