Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,
I have make one module for TimeSheet.In that When I click on Save button StartTaskTime,EndTaskTime,TaskDescription this record store in table.That is I have implemented.
but I get some problem.like One`s I will click on Save button record is store but when I refresh this page again this record is added into table.
I dont what the problem and how I solve.
I hope you give me some Idea about this to solve this problem.


Thank you on advanced...
Posted
Comments
phil.o 9-Dec-15 7:37am    
Please show us the relevant parts of your code, where you are inserting into DB and where you are retrieving values from DB.
Member 12097108 9-Dec-15 7:57am    
suppose sir,
I have two dropdown and one textbox.
from dropdown1 I was select 8AM
from dropdown2 I was select 9AM
In textbox we enter value like Task1.
after i click on save button.so this 3 record inserted into database.That i have implemented.now when I will refresh the page from (f5) that time this same record again inserted into databse
phil.o 9-Dec-15 8:03am    
Yes, but this does not answer my question. We need to see the code you have so far which is causing your problem.
Please use the "Improve question" button.
Member 12097108 9-Dec-15 8:36am    
Ok sir..I will share my code..
protected void LinkButton2_Click(object sender, EventArgs e)
{

if (ViewState["CurrentTable"] != null)
{
DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
DataRow drCurrentRow = null;
if (dtCurrentTable.Rows.Count > 0)
{
drCurrentRow = dtCurrentTable.NewRow();
drCurrentRow["RowNumber"] = dtCurrentTable.Rows.Count + 1;
dtCurrentTable.Rows.Add(drCurrentRow);
ViewState["CurrentTable"] = dtCurrentTable;
TimeSpan time = new TimeSpan();
for (int i = 0; i < dtCurrentTable.Rows.Count - 1; i++)
{
DropDownList ddl1 = (DropDownList)GridView1.Rows[i].Cells[1].FindControl("DropDownList1");
DropDownList ddl2 = (DropDownList)GridView1.Rows[i].Cells[2].FindControl("DropDownList2");
dtCurrentTable.Rows[i]["Column1"] = ddl1.SelectedItem.Text;
dtCurrentTable.Rows[i]["Column2"] = ddl2.SelectedItem.Text;
TextBox box1 = (TextBox)GridView1.Rows[i].Cells[3].FindControl("TextBox1");
dtCurrentTable.Rows[i]["Column3"] = box1.Text;
Label lbl1 = (Label)GridView1.Rows[i].Cells[4].FindControl("Label2");
System.DateTime time1 = new System.DateTime();
System.DateTime time2 = new System.DateTime();
time1 = DateTime.Parse(ddl1.SelectedItem.Text);
time2 = DateTime.Parse(ddl2.SelectedItem.Text);
TimeSpan ts = time2.Subtract(time1);
lbl1.Text = Convert.ToString(ts);
time = time + ts;
// Label3.Text = Convert.ToString(time);
dtCurrentTable.Rows[i]["Column4"] = lbl1.Text;

DailyTimeSheetTrackers objTimeTracker = new DailyTimeSheetTrackers();

objTimeTracker = new DailyTimeSheetTrackers();
objTimeTracker.EmployeeId = UserLog.UserId;
objTimeTracker.CreateDateTime = StaticKeys.getLocaleDatefromUTC();
objTimeTracker.CreateUserId = UserLog.UserId;
objTimeTracker.TaskTimeIn = DateTime.Parse(ddl1.SelectedItem.Text);
objTimeTracker.TaskTimeOut = DateTime.Parse(ddl2.SelectedItem.Text);
objTimeTracker.TaskDescription = box1.Text;
objTimeTracker.Status = true;
if (!(new DailyTimeSheetTrackersFactory()).Insert(objTimeTracker))
{
//ltrError.Text = objTimeTracker.BrokenRulesList.ToString();
//dvError.Visible = true;
return;
}

}
}
//Insert();
}
phil.o 9-Dec-15 8:39am    
No code in comments. I won't ever read it. Please use the "Improve question" button.

1 solution

I believe you are having repeated request problem. Check this cool Prevent Repeated Requests using ActionFilters in ASP.NET MVC[^] article for a solution
 
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