Click here to Skip to main content
16,012,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 3 radio buttons and i want to add 30 or 60 or 90 days to the date.

This is my code.
C#
protected void gvImages_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\site\SamsungClassifieds\App_Data\Dorknozzle.mdf;Integrated Security=True;User Instance=True");
        con.Open();
        
        //DateTime date = DateTime.Now;
        //date = date.AddDays(30);
        //int userid = Convert.ToInt32(gvImages.DataKeys[e.RowIndex].Values["lbladid"].ToString());
        Label lbladid = (Label)gvImages.Rows[e.RowIndex].FindControl("lbladid");
        TextBox txttitle = (TextBox)gvImages.Rows[e.RowIndex].FindControl("txttitle");
        TextBox txtdesc = (TextBox)gvImages.Rows[e.RowIndex].FindControl("txtdesc");
        Label lblprice = (Label)gvImages.Rows[e.RowIndex].FindControl("lblprice");
        TextBox txtprice = (TextBox)gvImages.Rows[e.RowIndex].FindControl("txtprice");
        RadioButton rd1 = (RadioButton)gvImages.Rows[e.RowIndex].FindControl("rb30");
        RadioButton rd2 = (RadioButton)gvImages.Rows[e.RowIndex].FindControl("rb60");
        RadioButton rd3 = (RadioButton)gvImages.Rows[e.RowIndex].FindControl("rb90");
      
        
            SqlCommand cmd = new SqlCommand("UPDATE AD_DETAIL SET AD_TITLE ='" + txttitle.Text + "',AD_DESC ='" + txtdesc.Text + "',AD_PRICE ='" + txtprice.Text + "'WHERE AD_ID = '" + lbladid.Text + "'", con);
            
            cmd.ExecuteNonQuery();
            gvImages.EditIndex = -1;
            Binddata();
            con.Close();
        

    }
Posted
Updated 7-Aug-13 1:33am
v2

1 solution

daterequired = DateAdd(DateInterval.Day, 30, Now.Date)... replace 30 with 60 or 90 as required.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900