TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vignesh Kumar
NA
1k
418.3k
Unable to update converted datatype column
Feb 18 2014 2:03 AM
Hi,
I am using the below code to update my grid rows. Since my dollar column is of int datatype and I want to show them as western number system, I had done some conversions to display the dollar values like this " $ 100,00". Also when I update I am using the below code to trim the dollar and empty space for dollar column.
string Dollar = Dollars.Text.ToString();
string RemoveDollar = Dollar.Substring(2, Dollar.Length - 2);
Code:
protected void Details_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox Code = (TextBox)ODetails.Rows[e.RowIndex].FindControl("txtCode");
TextBox Date = (TextBox)Details.Rows[e.RowIndex].FindControl("txtDate");
TextBox Dollars = (TextBox)Details.Rows[e.RowIndex].FindControl("txtDollars");
TextBox Funding = (TextBox)Details.Rows[e.RowIndex].FindControl("txtFunding");
sring Dollar = Dollars.Text.ToString();
string RemoveDollar = Dollar.Substring(2, Dollar.Length - 2);
SqlConnection conn = new SqlConnection(CS);
Details.EditIndex = -1;
conn.Open();
SqlCommand cmd = new SqlCommand("Update Application set Date= '" + Date.Text + "', Funding= '" + Funding.Text + "' where Code= '" + Code.Text + "' and '$ ' + replace(convert(varchar(100), convert(money, Dollar_Amount), 1), '.00', '')= '" + Dollars.Text + "'", conn); cmd.ExecuteNonQuery(); conn.Close();
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", "alert('Details updated successfully');", true);
BindGrid();
}
Except Dollar column I am able to update remaining fields.
Reply
Answers (
4
)
gridview Checkbox value
updating record automatically