Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi

i m just inserting values...code is running without any error till end ...i have checked at different points. just its fail when i take value from textarea in 'req'.....and its not inserting in db as well. Table name is "RequestPay"....

ProjContext objCont = new ProjContext();
int item1 = int.Parse(dd_LeavDayFrom.SelectedItem.Value);
int item2 = int.Parse(dd_LeavMonthFrom.SelectedItem.Value);
int item3 = int.Parse(dd_LeavYearFrom.SelectedItem.Value);

int item4 = int.Parse(dd_Leav_dayTo.SelectedItem.Value);
int item5 = int.Parse(dd_Leav_MonTo.SelectedItem.Value);
int item6 = int.Parse(dd_Leav_YearTo.SelectedItem.Value);

DateTime dt = new DateTime(item3, item2, item1);
DateTime dt1 = new DateTime(item6, item5, item4);

RequestLeave req = new RequestLeave();
req.UName = txt_LeavEmpName.Text;
req.DateFrom = dt;
req.DateTo = dt1;
req.ReqReason = TextArea1.Text;

objCont.RequestLeaves.InsertOnSubmit(req);
objCont.SubmitChanges();
lbl_LeavSnt.Visible = true;


please anybody could help.... :(( :( :confused::confused:

[edit]"[code]" converted to code block, "ignore HTML..." option deselected - OriginalGriff[/edit]
Posted
Updated 29-Jan-11 5:30am
v2
Comments
OriginalGriff 29-Jan-11 11:32am    
When you say "just its fail when i take value from textarea in 'req'." what do you mean?
Is there an error? If so, what is it?
If not, what does (or doesn't) happen?
Abhishek Sur 29-Jan-11 11:50am    
Can you check weather TextArea1.Text has value?

What is the data type of ReqReason ? is it String ?
marileena 29-Jan-11 12:55pm    
@OriginalGriff...there is not any error...thats what makes me rash. and it simply executes the next line i.e lbl_LeavSnt.Visible = true; but doesnot put values in db.
.
@Sur.....yeah have checked all. datatyp of ReqReason is varchar(50).
Abhishek Sur 29-Jan-11 14:49pm    
@marileena You said when you step through the TextArea1.Text it shows the value, is it right?
For this can step through InsertOnSubmit or open Sql Server Profiler to see what Insert statement it creates ?
marileena 30-Jan-11 6:37am    
@abhishek.....no i didnt say. i said...Only TextArea1.Text is not displaying information and InsertOnSubmit statement is not working...no error encountered but not putting values in db as well.:((

Are you populating the form without doing it inside:

if (!IsPostBack)
{
   // Populate forms fields.
}


Without the above construct (in the OnLoad event of the form or wherever it is you populate the form from) you will get the default state of the textbox when you click the button and postback to collect the form field values; presumably it is empty at that point.

Just a guess.
 
Share this answer
 
what you suggest???

em working under button click event ...here should i write
C#
if(!IsPostBack)
{
}



is it you suggest??
 
Share this answer
 
v3
Comments
R. Giskard Reventlov 30-Jan-11 3:10am    
Firstly, don't respond to an answer with an answer: use a comment. Secondly, re-read my answer: everything you need is in there.
marileena 30-Jan-11 6:38am    
Ok...ll be careful next time:)

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