1
Reply

how to refresh a page in mvc

sourabh choubey

sourabh choubey

Jul 19 2016 2:30 AM
200
 
the following action link does not bind data between two date but its bind the default list when the page is first displayed .EveryTime it binds default list.I am Sending this to partial page which in inside view page..
public ActionResult SearchByTodate(string fdate, string todate)
{
SecretaryUserModel secretarymodel = new SecretaryUserModel();
ExpensesBL expbl = new ExpensesBL();
var expenseslist = expbl.GetExpensesList();
foreach (var data in expenseslist)
{
secretarymodel.ExpensesList.Add(new SelectListItem
{
Text = data.Expenses_Name,
Value = data.ID.ToString(),
});
}
secretarymodel.selectedexpensesid = secretarymodel.Expenses_ID;
secretarymodel.ExpensesList.Add(new SelectListItem
{
Text = "All",
Value = "0",
Selected = true
});
ParticularsBL objparticulars = new ParticularsBL();
DateTime frdate = Convert.ToDateTime(fdate);
DateTime tdate = Convert.ToDateTime(todate);
DataTable searchbydate = OBJ.Fetch_PartDetailsBytdate(frdate, tdate);
var builder = new StringBuilder();
if (searchbydate.Rows.Count > 0)
{
int i = 0;
builder.Append("<table class='table table-striped table-bordered table-hover' id='sample_1'>");
builder.Append("<thead>");
builder.Append("<tr class='app'>");
builder.Append("<th style='display:none'>");
builder.Append("</th>");
builder.Append("<th style='display:none'>");
builder.Append("</th>");
builder.Append("<th class='table-checkbox'>");
builder.Append("<input type='checkbox' class='group-checkable' data-set='#sample_Customer .checkboxes' />");
builder.Append("</th>");
int conditionforth = 0;
foreach (DataColumn dc in searchbydate.Columns)
{
string str = Convert.ToString(searchbydate.Columns[i].ColumnName.ToString());
if ((str == "SLNO"))
builder.Append("<th>");
if (str == "TransactionDate")
builder.Append("<th class='center' style='text-align:left'>");
if (str == "Particular")
builder.Append("<th class='boxname' style='text-align:left'>");
if (conditionforth >= 3)
{
builder.Append("<th class='boxService' style='text-align:left'>");
}
conditionforth++;
builder.Append(str);
builder.Append("</th>");
i++;
}
if (conditionforth >= 3)
builder.Append("<th class='boxService' style='text-align:left'>");
builder.Append("Remarks");
builder.Append("</th>");
if (conditionforth >= 3)
builder.Append("<th class='boxService' style='text-align:left'>");
builder.Append("Action");
builder.Append("</th>");
builder.Append("</tr>");
builder.Append("</thead>");
int row = 0;
builder.Append("<tbody>");
builder.Append("<tr class='odd gradeX'>");
builder.Append("<td>");
builder.Append("</td>");
builder.Append("</tr>");
foreach (DataRow dr in searchbydate.Rows)
{
int column = 0;
builder.Append("<tr class='odd gradeX'>");
builder.Append("<td>");
builder.Append("<input type='checkbox' class='checkboxes' value='1' id='" + Convert.ToInt32(searchbydate.Rows[row][0]) + "'>");
builder.Append("</td>");
foreach (DataColumn dc in searchbydate.Columns)
{
builder.Append("<td>");
builder.Append(Convert.ToString(searchbydate.Rows[row][column]));
builder.Append("</td>");
column++;
}
builder.Append("<td>");
builder.Append("Paid");
builder.Append("</td>");
builder.Append("<td>");
int id = Convert.ToInt32(searchbydate.Rows[row][0]);
if (id > 0)
{
builder.Append("<a href='#' class='btn' type='button' onclick='ViewUser('" + id + "')><i class='icon-pencil'></i></a>");
builder.Append("<a href='@URL.Action('DeleteParticulars','SecretaryUser',new{ID='" + id + "'})' onclick='return confirm('Are u sure to Delete Particulars Records.')'><i class='icon-trash'></i></a>");
}
else
{
builder.Append("<a href='#' class='btn' type='button' onclick='ViewUser('" + id + "')><i class='icon-pencil'></i></a>");
}
builder.Append("</td>");
builder.Append("</tr>");
row++;
}
builder.Append("</tbody>");
builder.Append("</table>");
string strblder = builder.ToString();
ViewBag.testing = builder.ToString();
}
else
{
builder.Append("<table class='table table-striped table-bordered table-hover' id='sample_1'>");
builder.Append("<thead>");
builder.Append("<tr class='app'>");
builder.Append("<th style='display:none'>");
builder.Append("</th>");
builder.Append("<th style='display:none'>");
builder.Append("</th>");
builder.Append("<th class='table-checkbox'>");
builder.Append("<input type='checkbox' class='group-checkable' data-set='#sample_Customer .checkboxes' />");
builder.Append("</th>");
int conditionforth = 0;
int i = 0;
foreach (DataColumn dc in searchbydate.Columns)
{
string str = Convert.ToString(searchbydate.Columns[i].ColumnName.ToString());
if ((str == "SLNO"))
builder.Append("<th>");
if (str == "TransactionDate")
builder.Append("<th class='center' style='text-align:left'>");
if (str == "Particular")
builder.Append("<th class='boxname' style='text-align:left'>");
if (conditionforth >= 3)
{
builder.Append("<th class='boxService' style='text-align:left'>");
}
conditionforth++;
builder.Append(str);
builder.Append("</th>");
i++;
}
if (conditionforth >= 3)
builder.Append("<th class='boxService' style='text-align:left'>");
builder.Append("Remarks");
builder.Append("</th>");
if (conditionforth >= 3)
builder.Append("<th class='boxService' style='text-align:left'>");
builder.Append("Action");
builder.Append("</th>");
builder.Append("</tr>");
builder.Append("</thead>");
//int row = 0;
builder.Append("<tbody>");
builder.Append("<tr class='odd gradeX'>");
builder.Append("<td>");
builder.Append("</td>");
builder.Append("</tr>");
builder.Append("</table>");
ViewBag.testing = builder.ToString() ;
}
return View();
}

Answers (1)