0

Assume i have a table
field1, field2, field3
and i have radio button list that displaying field1, field2, field3

If the end-user selected field2 and inserting a value into field2
How can i do? Any Tricks?
Thanks for in advance.

2
Contributors
3
Replies
19
Views
3 Years
Discussion Span
Last Post by mmcdonald
0

Well done on self-answering, but would you care to share your solution incase another user runs into the same issue?

Michael

0
        protected void AddTransaction(object sender, EventArgs e)
        {
            double amount = Convert.ToDouble(txtAmount.Text) + isContainValue();

            SqlConnection conAddTransaction = new SqlConnection(ConfigurationManager.ConnectionStrings["connMSJ"].ConnectionString);
            SqlCommand cmdUpdateTransaction = new SqlCommand(String.Format("UPDATE DailyBudget SET {0}=@amount WHERE (Username=@username AND Date=@date)", radCategory.SelectedValue), conAddTransaction);
            SqlCommand cmdAddTransaction = new SqlCommand(String.Format("INSERT INTO DailyBudget (Username, Date, {0}) VALUES (@username, @date, @amount)", radCategory.SelectedValue), conAddTransaction);
            cmdUpdateTransaction.Parameters.AddWithValue("@username", Master.getUsername);
            cmdUpdateTransaction.Parameters.AddWithValue("@date", DateTime.Now.Date);
            cmdUpdateTransaction.Parameters.AddWithValue("@amount", amount);

            cmdAddTransaction.Parameters.AddWithValue("@username", Master.getUsername);
            cmdAddTransaction.Parameters.AddWithValue("@date", DateTime.Now.Date);
            cmdAddTransaction.Parameters.AddWithValue("@amount", amount);
            conAddTransaction.Open();
            if (totalUsage != 0)
                cmdUpdateTransaction.ExecuteNonQuery();
            else
                cmdAddTransaction.ExecuteNonQuery();
            conAddTransaction.Close();

            totalUsage += Convert.ToDouble(txtAmount.Text);
            updateCurrentBudget(getRemainBudget(Convert.ToDouble(txtAmount.Text)));
            Response.Redirect("~/Member/Home.aspx");
        }

Sorry for that. Happy Coding Folks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.