Click here to Skip to main content
15,867,328 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
i have used javascript.Value from this javascript i have fill textbox.textbox is now fill with value(Ex:200) But problem is ..when this textbox is disable,value in it cannot be inserted into database.if textbox is not disable then value is insert in database.
i have to do textbox disable and insert value into database.how i can do this?
Posted
Updated 25-Jan-13 10:32am
v2
Comments
Richard C Bishop 25-Jan-13 16:33pm    
What method are you using to update or insert into a datase and what type of database?
Member 9511889 25-Jan-13 16:45pm    
SqlCommand cmd = new SqlCommand("insert into StudentFees(" + Convert.ToInt16(ddlstudentname.SelectedValue) + "," + Convert.ToInt64(txt_totalfees.Text) + "," + Convert.ToDateTime(txtNextPaymentDate.Text) + "'," + Convert.ToInt64(txt_nextpaymentAmt.Text) + ")", cnn);

total fees is comming from javascript.i have to store it in sql table "studentfees"
Richard C Bishop 25-Jan-13 17:31pm    
Well I am not sure what event this insert statement is taking place so I can't tell what the problem is. But if you are disabling the textbox onblur then it won't get the value to the database because it is essentially invisible after disabling it. Also, your insert statement does not specify columns to insert your values into.
Prosan 26-Jan-13 3:47am    
how you disable text box
Tharaka MTR 28-Jan-13 1:46am    
please send us code sample

Dont disable textbox.
User ReadOnly = true;
or Enabled = false;
or Visible = false;
 
Share this answer
 
Please make the textbox property to readonly.If you disabled the Textbox property the value cannot be read.

Thanks
 
Share this answer
 
Don't disable the TextBox in the CodeBehind, add the attribute

means

TextBox1.Enabled = false;


instead of this use below code..

TextBox1.Attributes.Add("disabled", true);
 
Share this answer
 
since you have set its value using javascript you will be required to use the following way to get the value

C#
string myValue = Request["txt_totalfees"].ToString();
 
Share this answer
 
It will be great if you could share little more details about when you are inputing data and when you disable it.... but based on the info you provided.. I would say

Maintain a hidden text field which can capture the data from disabled field, and use the hidden field for retrieving data.
 
Share this answer
 
Comments
[no name] 27-Jan-13 5:05am    
+5

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