hi
i have a page like generating reports according to task wise.the page have a dropdown list fro selecting the task..every task has start date and end date.
when user select the task according to the difference between dates i want to generate the the that different file upload controls..if the difference is 7 days 7 upload ocntrols will be present..once one file is uploaded that control is disabled.. and that file will be saved in local folder of project
plz help me writing this code
Loading
Dorababu MekaPosted Aug 30, 2011, 9:22 AM
string fname = "Report";
fname = fname + Guid.NewGuid();
So a unique file will get generated.
Bhanuprakash BysaniPosted Aug 30, 2011, 8:33 AM
Dorababu MekaPosted Aug 30, 2011, 8:19 AM
Bhanuprakash BysaniPosted Aug 30, 2011, 8:10 AM
Dorababu MekaPosted Aug 30, 2011, 8:08 AM
Bhanuprakash BysaniPosted Aug 30, 2011, 8:04 AM
Dorababu MekaPosted Aug 30, 2011, 7:57 AM
Bhanuprakash BysaniPosted Aug 30, 2011, 7:54 AM
Dorababu MekaPosted Aug 30, 2011, 7:10 AM
Bhanuprakash BysaniPosted Aug 30, 2011, 6:37 AM
Dorababu MekaPosted Aug 30, 2011, 6:12 AM
and check once.
Bhanuprakash BysaniPosted Aug 30, 2011, 5:14 AM
Dorababu MekaPosted Aug 30, 2011, 3:55 AM
You have written this in your code
datediff = UBLOBJ.GetDateDifference(UPOBJ);
means you are getting the count if controls are properly getting as per your code then there is no issue with the code so first confirm whether you are getting the controls correctly or not
Bhanuprakash BysaniPosted Aug 30, 2011, 12:59 AM
u r declared default the datediff is 7.in my code it is coming form datbase so wher i can modify to get uploadFilCol.Count is also 7..
Dorababu MekaPosted Aug 29, 2011, 9:11 AM
Dorababu MekaPosted Aug 29, 2011, 9:04 AM
Bhanuprakash BysaniPosted Aug 29, 2011, 9:01 AM
HttpFileCollection uploadFilCol = Request.Files;
where i can modify
Dorababu MekaPosted Aug 29, 2011, 8:22 AM
Bhanuprakash BysaniPosted Aug 29, 2011, 8:10 AM
Dorababu MekaPosted Aug 29, 2011, 8:04 AM
As per your code the file upload will not be shown on the form as you are creating it dynamically.
If i am wrong post you sample form that is having the file upload controls as per your condition
Bhanuprakash BysaniPosted Aug 29, 2011, 7:42 AM
{
UPOBJ.U_UserID = HttpContext.Current.User.Identity.Name.ToString();
if (!IsPostBack)
{
ds = UBLOBJ.GetAssignedTasksByUserId(UPOBJ);
ddlTask.DataSource = ds;
ddlTask.DataTextField = ds.Tables[0].Columns[1].ColumnName.ToString();
ddlTask.DataBind();
ddlTask.Items.Insert(0, "Select The Task");
}
}
protected void ddlTask_SelectedIndexChanged(object sender, EventArgs e)
{
Addcontrols();
}
public void Addcontrols()
{
panelreport.Controls.Remove(fu);
panelreport.Controls.Clear();
UPOBJ.U_TaskName = ddlTask.SelectedItem.Text.ToString();
datediff = UBLOBJ.GetDateDifference(UPOBJ);
lb1 = new Label();
panelreport.Controls.Add(lb1);
lb1.Text = "The Total Days assigned For the task to complete:" + datediff.ToString();
for (int i = 1; i <= datediff; i++)
{
panelreport.Controls.Add(new LiteralControl("
"));
panelreport.Controls.Add(new LiteralControl("
"));
fu = new FileUpload();
fu.ID = i.ToString();
lb = new Label();
panelreport.Controls.Add(lb);
lb.Text = "Report For Day:" + i.ToString();
panelreport.Controls.Add(fu);
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
}
My code is like this..in button click event all reports wikll be uploaded...plz help me in writing the code..
Dorababu MekaPosted Aug 29, 2011, 7:22 AM
HttpFileCollection uploadFilCol = Request.Files;
for (int i = 0; i < uploadFilCol.Count; i++)
{
HttpPostedFile file = uploadFilCol[i];
string fileExt = Path.GetExtension(file.FileName);
string fileName = Path.GetFileName(file.FileName);
if (fileName != string.Empty)
{
try
{
file.SaveAs(Server.MapPath("./Foldername/") + fileName);
}
catch (Exception ex)
{
}
}
}
Bhanuprakash BysaniPosted Aug 29, 2011, 7:08 AM
Dorababu MekaPosted Aug 29, 2011, 7:06 AM
Bhanuprakash BysaniPosted Aug 29, 2011, 6:21 AM
how to identify the dynamically crated controls and that reports will be saved in local folders
Dorababu MekaPosted Aug 29, 2011, 6:18 AM
Bhanuprakash BysaniPosted Aug 29, 2011, 6:17 AM
Dorababu MekaPosted Aug 29, 2011, 6:15 AM