PagedDataSource not paging - c#

i have serched all over the web and didnt find anything like what i am doing or any solution to my problam.
i have an xsd file that connects to mdb and i want to show 10 resukts at a time and to have the ability to page throw all the results,for now the status is that i get 62 results per page and when i am trying to go to the next page i dont recive any results.
what is wrong in my code
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="MainPage.aspx.cs"
Inherits="FaceBookSearchN.MainPage" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%--<%# Register Src="~/ResultsControl.ascx" TagPrefix="Results" TagName="ResultsControl" %>--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<style type="text/css">
.accordionHeader
{
border: 1px solid blue;
color: White;
background-color: #5078B3;
font-family: Arial,Sans-Serif;
font-size: 12px;
font-weight: bold;
padding: 5px;
margin-top: 5px;
cursor: pointer;
}
.accordionHeader a, .accordionHeaderSelected a
{
color: #ffffff;
background: none;
text-decoration: none;
}
.accordionHeader a:hover, .accordionHeaderSelected a:hover
{
background: none;
text-decoration: underline;
}
.accordionHeaderSelected
{
border: 1px solid #2f4f4f;
color: White;
background-color: #5078B3;
font-family: Arial, Sans-Serif;
font-size: 12px;
font-weight: bold;
padding: 5px;
cursor: pointer;
}
.accordionContent
{
background-color: White;
border: 1px solid,#2f4f4f;
border-top: none;
padding: 5px;
padding-top: 10px;
}
</style>
<title></title>
</head>
<body dir="rtl">
<form id="form1" runat="server">
<div>
<table width="520px">
<tr>
<td>
<table width="100%">
<tr>
<td>
<asp:Label runat="server" Text="תחום" ID="lblProffesion"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:DropDownList runat="server" ID="ddlProffesion" DataTextField="profession_name"
DataValueField="profession_id" OnSelectedIndexChanged="ddlProffesion_SelectedIndexChanged"
AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
</table>
</td>
<td>
<table width="100%">
<tr>
<td>
<asp:Label runat="server" Text="אזור" ID="lblArea"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:DropDownList runat="server" ID="ddlArea" DataValueField="id_area" DataTextField="name_area"
AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%">
<tr>
<td>
<asp:Label runat="server" Text="תפקיד" ID="lblSubProffesion"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:DropDownList runat="server" ID="ddlSubProffesion" DataValueField="tat_pofession_id"
DataTextField="tat_pofession_name" AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
</table>
</td>
<td>
<table width="100%">
<tr>
<td>
<asp:Label runat="server" Text="אזור כתיבה חופשי" ID="lblFreetext"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtFreetext"></asp:TextBox>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button runat="server" Text="חיפוש" ID="btnSearch" OnClick="btnSearch_Click" />
</td>
</tr>
</table>
<div style="width: 520px">
<table width="520px" id="tblHeader" runat="server" style="background-color: #5078B3;
height: 25px">
<tr>
<td>
<asp:Label runat="server" ID="lblJobNum" Text="מס' משרה"></asp:Label>
</td>
<td>
<asp:Label runat="server" ID="lblJobName" Text="שם משרה"></asp:Label>
</td>
<td>
<asp:Label runat="server" ID="lblJobArea" Text="אזור עבודה"></asp:Label>
</td>
</tr>
</table>
<asp:Accordion ID="Accordion1" runat="server" AutoSize="None" FramesPerSecond="40" SelectedIndex="0" TransitionDuration="100"
FadeTransitions="true" RequireOpenedPane="true" SuppressHeaderPostbacks="true"
ContentCssClass="accordionContent" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected">
</asp:Accordion>
<asp:Label ID="lblCurrentPage" runat="server"></asp:Label>
<asp:Button ID="btnPrev" runat="server" Text=" << " />
<asp:Button ID="btnNext" runat="server" Text=" >> " />
</div>
</div>
<asp:ToolkitScriptManager ID="Toolkitscriptmanager1" runat="server">
</asp:ToolkitScriptManager>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.UI.HtmlControls;
namespace FaceBookSearchN
{
public partial class MainPage : System.Web.UI.Page
{
private DataConnectionTableAdapters.table_professionTableAdapter adapterProf;
private DataConnectionTableAdapters.table_profession_tatTableAdapter adapterSubProf;
private DataConnectionTableAdapters.table_areaTableAdapter adapterArea;
private DataConnectionTableAdapters.ordersTableAdapter adapterOrdersNoParams;
private DataConnectionTableAdapters.ordersWithParamsTableAdapter adapterOrdersWithParams;
private DataConnection.table_professionDataTable profDT;
private DataConnection.table_profession_tatDataTable SubProfDT;
private DataConnection.table_areaDataTable areaDT;
private DataConnection.ordersDataTable ordersNoParamsDT;
private DataConnection.ordersWithParamsDataTable ordersWithParamsDT;
PagedDataSource pds;
public int CurrentPage
{
get
{
object o = this.ViewState["CurrentPage"];
if (o == null)
return 0;
else
return (int)o;
}
set
{
this.ViewState["CurrentPage"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
OnLoad();
}
}
protected void OnLoad()
{
tblHeader.Visible = false;
profDT = new DataConnection.table_professionDataTable();
adapterProf = new DataConnectionTableAdapters.table_professionTableAdapter();
areaDT = new DataConnection.table_areaDataTable();
adapterArea = new DataConnectionTableAdapters.table_areaTableAdapter();
adapterProf.Fill(profDT);
adapterArea.Fill(areaDT);
//adapter.Fill(SubProfDT);
ddlProffesion.DataSource = profDT;
ddlProffesion.DataBind();
ddlProffesion.Items.Insert(0,new ListItem("בחר מקצוע", "0"));
ddlArea.DataSource = areaDT;
ddlArea.DataBind();
ddlArea.Items.Insert(0, new ListItem("בחר אזור", "0"));
ddlSubProffesion.Items.Insert(0, new ListItem("בחר תת מקצוע", "0"));
}
protected void ddlProffesion_SelectedIndexChanged(object sender, EventArgs e)
{
SubProfDT = new DataConnection.table_profession_tatDataTable();
adapterSubProf = new DataConnectionTableAdapters.table_profession_tatTableAdapter();
adapterSubProf.GetDataByID(int.Parse(ddlProffesion.SelectedValue));
SubProfDT = adapterSubProf.GetDataByID(int.Parse(ddlProffesion.SelectedValue));
ddlSubProffesion.DataSource = SubProfDT;
ddlSubProffesion.DataBind();
//ddlSubProffesion.Items.Insert(0, new ListItem("בחר תת מקצוע", "0"));
}
protected void btnSearch_Click(object sender, EventArgs e)
{
tblHeader.Visible = true;
if (int.Parse(ddlProffesion.SelectedValue) == 0 && int.Parse(ddlArea.SelectedValue) == 0)
{
ordersNoParamsDT = new DataConnection.ordersDataTable();
adapterOrdersNoParams = new DataConnectionTableAdapters.ordersTableAdapter();
adapterOrdersNoParams.FillOrdersNoParams(ordersNoParamsDT);
DataTable dt = new DataTable();
dt = ordersNoParamsDT;
pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
pds.AllowPaging = true;
pds.PageSize = 10;
pds.CurrentPageIndex = CurrentPage;
lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " " + "of" + " " + pds.PageCount.ToString();
btnPrev.Enabled = !pds.IsFirstPage;
btnNext.Enabled = !pds.IsLastPage;
ViewState["totalpages"] = pds.PageCount;
for (int i = 0; i < pds.PageCount; i++)
{
FileUpload fu = new FileUpload();
Button btnSubmit = new Button();
btnSubmit.Text = "שלח קורות חיים";
AjaxControlToolkit.AccordionPane pn;
pn = new AjaxControlToolkit.AccordionPane();
pn.ID = "pane" + i;
Label lblTitle = new Label();
Label lblJobName = new Label();
Label lblDesc = new Label();
lblTitle.Text = dt.Rows[i]["order_id"].ToString();
lblJobName.Text = dt.Rows[i]["description"].ToString();
//lblDesc.Text = dt.Rows[i]["description"].ToString();
//Accordion1.DataSource = pds;
//Accordion1.DataBind();
pn.HeaderContainer.Controls.Add(lblTitle);
pn.HeaderContainer.Controls.Add(lblJobName);
HtmlTable tableDesc = new HtmlTable();
HtmlTableRow row;
HtmlTableCell cell;
cell = new HtmlTableCell();
row = new HtmlTableRow();
cell.InnerHtml = dt.Rows[i]["notes"].ToString();
row.Cells.Add(cell);
tableDesc.Rows.Add(row);
fu.Width = Unit.Percentage(100.00);
pn.ContentContainer.Controls.Add(lblDesc);
pn.ContentContainer.Controls.Add(tableDesc);
pn.ContentContainer.Controls.Add(fu);
pn.ContentContainer.Controls.Add(btnSubmit);
Accordion1.Panes.Add(pn);
}
//int i = 0;
//foreach (DataRow dr in ordersNoParamsDT)
//{
// FileUpload fu = new FileUpload();
// AjaxControlToolkit.AccordionPane pn;
// pn = new AjaxControlToolkit.AccordionPane();
// pn.ID = "pane" + i;
// Label lblTitle = new Label();
// Label lblDesc = new Label();
// lblTitle.Text = dr["order_id"].ToString();
// //lblTitle.Text = "מס' משרה" +"|" + "שם משרה" +"|"+ "אזור עבודה"+ "|";
// pn.HeaderContainer.Controls.Add(lblTitle);
// lblDesc.Text = dr["description"].ToString();
// //pn.ContentContainer.Controls.Add(lblDesc);
// HtmlTable tableDesc = new HtmlTable();
// HtmlTableRow row;
// HtmlTableCell cell;
// HtmlTableCell cell2;
// cell = new HtmlTableCell();
// cell2 = new HtmlTableCell();
// row = new HtmlTableRow();
// cell.InnerHtml = dr["notes"].ToString();
// fu.Width = Unit.Percentage(100.00);
// cell2.Controls.Add(fu);
// row.Cells.Add(cell);
// tableDesc.Rows.Add(row);
// pn.ContentContainer.Controls.Add(tableDesc);
// Accordion1.Panes.Add(pn);
// i++;
//}
//Accordion1.DataSource = new System.Data.DataTableReader(ordersNoParamsDT);
//Accordion1.DataBind();
//ucResults.Proffesion = int.Parse(ddlProffesion.SelectedValue);
//ucResults.SubProffesion = 0;
//ucResults.Area = int.Parse(ddlArea.SelectedValue);
}
else
{
// ucResults.Proffesion = int.Parse(ddlProffesion.SelectedValue);
// ucResults.SubProffesion = int.Parse(ddlSubProffesion.SelectedValue);
// ucResults.Area = int.Parse(ddlArea.SelectedValue);
}
}
private void btnPrev_Click(object sender, System.EventArgs e)
{
// Set viewstate variable to the previous page
CurrentPage -= 1;
// Reload control
//ItemsGet();
}
private void btnNext_Click(object sender, System.EventArgs e)
{
// Set viewstate variable to the next page
CurrentPage += 1;
// Reload control
//ItemsGet();
}
}
}

Your OnLoad() method only triggers during the first page load. The data needs to be rebound every time the page is changed. Try removing the if(!IsPostBack) from the Page_Load method and see if it works.

Related

delayed rediraction asp.net

so I have a login page and I'm trying to have it say "the user doesn't exist" and have it redirect you to the signup page immediately after showing this message, but my current code simply redirects you without displaying the message.
sorry if the message is unclear, its the first time i ever write anything in here:)
ulogin.html page:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="ulogin.aspx.cs" Inherits="User_ulogin" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style5 {
position: absolute;
top: 62px;
left: 53px;
z-index: 1;
}
.auto-style6 {
position: absolute;
top: 140px;
left: 56px;
z-index: 1;
}
.auto-style7 {
position: absolute;
top: 67px;
left: 279px;
z-index: 1;
width: 289px;
}
.auto-style8 {
position: absolute;
top: 141px;
left: 304px;
z-index: 1;
width: 295px;
}
.auto-style9 {
position: absolute;
top: 207px;
left: 219px;
z-index: 1;
}
.auto-style11 {
position: absolute;
top: 277px;
left: 10px;
z-index: 1;
width: 256px;
}
.auto-style12 {
position: absolute;
top: 16px;
left: 244px;
z-index: 1;
}
</style>
</head>
<body style="z-index: 1; width: 1490px; height: 16px; position: absolute; top: 0px; left: 0px">
<form id="form1" runat="server">
<div style="width: 1400px; margin: 0 auto;">
<asp:Label ID="Label2" runat="server" CssClass="auto-style5" Text="username:" Font-Size="18pt" Font-Bold="True"></asp:Label>
<asp:Label ID="Label3" runat="server" CssClass="auto-style6" Text="password:" Font-Size="18pt" Font-Bold="True"></asp:Label>
<asp:TextBox ID="txtuser" runat="server" CssClass="auto-style7" BorderColor="Black" OnTextChanged="txtuser_TextChanged"></asp:TextBox>
<asp:TextBox ID="txtpass" runat="server" CssClass="auto-style8" BorderColor="Black" OnTextChanged="txtpass_TextChanged"></asp:TextBox>
<asp:Button ID="Button1" runat="server" CssClass="auto-style9" OnClick="Button1_Click" Text="connect now" BackColor="Azure" Font-Size="16pt" BorderColor="Black" />
<asp:HyperLink ID="HyperLink1" runat="server" CssClass="auto-style11" Font-Size="14pt" Font-Underline="True">lost your password? reset it now</asp:HyperLink>
**<asp:Label ID="lblsucc" runat="server" style="z-index: 1; left: 746px; top: 97px; position: absolute" Text="user dont exist" Visible="False"></asp:Label>**
<asp:Label ID="Label4" runat="server" CssClass="auto-style12" Font-Size="XX-Large" Text="Sign Now"></asp:Label>
</div>
</form>
</body>
</html>
ulogin.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class User_ulogin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblsucc.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
users user = new users();
admin adn = new admin(txtuser.Text, txtpass.Text);
user.User_Name = txtuser.Text;
user.Pass = txtpass.Text;
if (user.login(user))
{
Session["user"] = txtuser.Text;
Response.Redirect("homepage.aspx");
}
else
{
lblsucc.Visible = true;
}
if(user.ifexist(user))
Response.Redirect("uregister.aspx");
}
protected void txtuser_TextChanged(object sender, EventArgs e)
{
}
protected void txtpass_TextChanged(object sender, EventArgs e)
{
}
protected void ImageButton2_Click1(object sender, ImageClickEventArgs e)
{
Response.Redirect("homepage.aspx");
}
}
'''
the relevant classes codes:
''' public bool login(users us)
{
DataSet dsUser = new DataSet();
string stuser = "SELECT tblUsers.User_Name, tblUsers.User_Password FROM tblUsers WHERE(((tblUsers.User_Password) = '" + us.user_Name + "')AND((tblUsers.User_Password) = '" + us.Pass + "')); ";
dsUser = sql.chkData(stuser);
if (dsUser.Tables[0].Rows.Count > 0)
{
return true;
}
else return false;
}'''
'''public bool ifexist(users user)
{
bool chk = false;
DataSet dsUser = new DataSet();
string stuser = "SELECT tblUsers.User_Name FROM tblUsers WHERE(((tblUsers.User_Name) ='" + user.User_Name + "'));";
dsUser = sql.chkData(stuser);
if (dsUser.Tables[0].Rows.Count > 0)
chk = true;
return chk;
}'''

How to pass HTML code to email in ASP.Net MVC C#

I'm working on sending an email for order confirmation and I need to loop every items that the user order from my website. So, I use the foreach to load very items in the email but it return a html code.
string body = string.Empty;
using (StreamReader reader = new StreamReader(Server.MapPath(templatePath)))
{
body = reader.ReadToEnd();
}
var items = "";
foreach (var itemList in orderProducts)
{
items += "<tbody style=\"border: 0; border - bottom: 1px dashed #ccc;\"><tr>< td style = \"text-align:center;\" width = \"200\" >{ Image}</ td >< td style = \"text-align:left\" width = \"250\" >"+ itemList.Name + "</ td >< td style = \" text-align:center\" width = \"100\" >" + itemList.Quantity + "</ td >< td style = \" text-align:center\" width = \"100\" >" + itemList.Price +"</ td ></ tr ></ tbody > ";
}
body = body.Replace("{Items}", items);
System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(body, null, "text/html");
mailMessage.AlternateViews.Add(htmlView);
//Send message
System.Net.Mail.SmtpClient smtpClient = new
System.Net.Mail.SmtpClient(mailServer);
smtpClient.Port = 587;
smtpClient.Credentials = new
System.Net.NetworkCredential(senderMail,senderPassword);
smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);
my email template
<table cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse;margin-top:-20px;">
<thead style="border: 0;border-bottom: 1px dashed #ccc;">
<tr>
<td style=" text-align:center" width="200"><b>ITEMS ORDERED</b></td>
<td style=" text-align:center" width="250">NAME</td>
<td style=" text-align:center" width="100">QTY</td>
<td style=" text-align:center" width="100">PRICE</td>
</tr>
</thead>
{Items}
</table>
and here's the result in my email. How to read the html code? Thank you for helping me.
You are adding multiple <tbody> elements to your table but that isn't the main problem. You need to remove the extra spaces from your < tr and < td elements. See snippet below for example with and without spaces.
You should also use StringBuilder when manipulating strings like this as it's more efficient.
var sb = new StringBuilder();
foreach (var itemList in orderProducts)
{
sb.AppendLine("<tbody style=\"border: 0; border-bottom: 1px dashed #ccc;\">");
sb.AppendLine("<tr>");
sb.AppendLine("<td style=\"text-align:center;\" width=\"200\">{Image}</td>");
sb.AppendLine("<td style=\"text-align:left\" width=\"250\">"+ itemList.Name + "</td>");
sb.AppendLine("<td style=\"text-align:center\" width=\"100\">" + itemList.Quantity + "</td>");
sb.AppendLine("<td style=\"text-align:center\" width=\"100\">" + itemList.Price +"</td>");
sb.AppendLine("</tr>");
sb.AppendLine("</tbody>");
}
var items = sb.ToString();
<h1>Without Spaces</h1>
<table cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse;">
<thead style="border: 0;border-bottom: 1px dashed #ccc;">
<tr>
<td style=" text-align:center" width="200"><b>ITEMS ORDERED</b></td>
<td style=" text-align:center" width="250">NAME</td>
<td style=" text-align:center" width="100">QTY</td>
<td style=" text-align:center" width="100">PRICE</td>
</tr>
</thead>
</table>
<h1>With Spaces</h1>
<table cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse;">
< thead style="border: 0;border-bottom: 1px dashed #ccc;">
< tr>
< td style=" text-align:center" width="200"><b>ITEMS ORDERED</b></td>
< td style=" text-align:center" width="250">NAME</td>
< td style=" text-align:center" width="100">QTY</td>
< td style=" text-align:center" width="100">PRICE</td>
</ tr>
</ thead>
</ table>

C# DropDownList behaving strangely only on server, not local

I have a form with some text input fields and 3 comboboxes, and a submit button, which is intended to save the data of the form into a table on a database. So when I click the submit button, after some debugging, I found out that at the moment of clicking it, there is no selected value for the comboboxes, thus bringing up errors and exceptions, and obviously not saving the data into the DB. BUT not only that, in addition, after the submit button is clicked, the comboboxes lose all of their values and the complete list that filled them dissappears, as if they were not initialized.
The sad part of all this (since I'm aware I could just review my code some more) is that when I do exactly the same, with the exact same code (same dll's and everything) on my ASP.NET Visual Studio server (on my local machine) everything works perfect, hence I'm writting into the same remote database, and after clicking the submit button the data saves into the DB, and the form stays normal with all comboboxes as they were before clicking.
Why does this happen only on the server? Why can it write and read from the database with no problem at all on local?
I think it could be related to the PostBack on my Page_Load method (I initialize the comboboxes at it, but only if it is NOT a PostBack)... So could this be an issue related to how does the IIS server work with PostBacks which might be different than the local ASP.NET server?
EDIT
I am adding the HTML code of the form
<form id="form1" runat="server">
<div class="popup" style="border: 1px solid #000; width: 600px;">
<table style="height: 148px; width: 584px">
<tr>
<td class="style1">
<table>
<tr>
<td>
<abbr title="El N° de Folio le será otorgado luego de haber guardado la necesidad."><asp:Label ID="Labe" runat="server" Text="Folio *" class="innerControl"></asp:Label></abbr>
</td>
<td colspan="2">
<abbr title="El N° de Folio le será otorgado luego de haber guardado la necesidad."><asp:TextBox ID="folTB" runat="server" Width="70px" class="innerControl" Enabled="false"></asp:TextBox></abbr>
</td>
<td>
<asp:Label ID="Label4" runat="server" Text="Fecha" class="innerControl"></asp:Label>
</td>
<td colspan="3">
<asp:TextBox ID="fecTB" runat="server" Width="100px" class="innerControl" Enabled="false"></asp:TextBox>
<asp:CalendarExtender ID="TextBox1_CalendarExtender" runat="server"
Enabled="True" TargetControlID="fecTB" DefaultView="Years" PopupButtonID="calBTN"></asp:CalendarExtender>
<asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server"
FilterType="Numbers, Custom" ValidChars="-" TargetControlID="fecTB">
</asp:FilteredTextBoxExtender>
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnableScriptGlobalization="True">
</asp:ScriptManager>
</td>
</tr>
<tr>
<td style="padding-right: 20px;">
<asp:Label ID="Label7" runat="server" Text="Beneficiarios" class="innerControl"></asp:Label>
</td>
<td style="padding-right: 20px;" colspan="2">
<asp:TextBox ID="benTB" runat="server" class="innerControl" Width="70px" Text="0" Enabled="false"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server"
FilterType="Numbers" TargetControlID="benTB">
</asp:FilteredTextBoxExtender>
</td>
<td style="padding-right: 20px;">
<asp:Label ID="Label2" runat="server" Text="Intendencia" class="innerControl"></asp:Label>
</td>
<td colspan="3">
<asp:DropDownList ID="intDDL" runat="server" class="innerControl" Width="270px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label9" runat="server" Text="Mes / Año" class="innerControl"></asp:Label>
</td>
<td>
<asp:DropDownList ID="mesDDL" runat="server" class="innerControl">
</asp:DropDownList>
</td>
<td>
/
</td>
<td>
<asp:DropDownList ID="anoDDL" runat="server" class="innerControl">
</asp:DropDownList>
</td>
<td style="width: 50px;">
<asp:Label ID="Label1" runat="server" Text="_________" class="innerControl" ForeColor="White"></asp:Label>
</td>
<td>
<asp:Label ID="Label10" runat="server" Text="Meses" class="innerControl"></asp:Label>
</td>
<td>
<asp:TextBox ID="mesesTB" runat="server" Width="77px" class="innerControl"
Height="23px"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="TBExtender" runat="server"
FilterType="Numbers" TargetControlID="mesesTB">
</asp:FilteredTextBoxExtender>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<br />
<asp:Label runat="server" Text="Características del Requerimiento:" class="popup"></asp:Label>
<br />
<div class="popup" style="border: 1px solid #000; width: 600px;">
<table style="height: 100px; width: 584px">
<tr>
<td class="style1">
<table>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Población:" class="innerControl"></asp:Label>
</td>
<td colspan="2">
<asp:TextBox ID="pobTB" runat="server" Width="70px" class="innerControl"></asp:TextBox>
</td>
<td>
<asp:Label ID="Label5" runat="server" Text="Fundamentación:" class="innerControl"></asp:Label>
</td>
<td rowspan="3">
<asp:TextBox ID="fundTB" runat="server" Width="221px" class="innerControl"
TextMode="MultiLine" Rows="7" Columns="35"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-right: 20px;">
<asp:Label ID="Label6" runat="server" Text="Tasa Desempleo:" class="innerControl"></asp:Label>
</td>
<td style="padding-right: 20px;">
<asp:TextBox ID="empTB" runat="server" class="innerControl" Width="70px" ></asp:TextBox>
<asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server"
FilterType="Numbers, Custom" ValidChars=".," TargetControlID="empTB">
</asp:FilteredTextBoxExtender>
</td>
<td>
%
</td>
</tr>
<tr>
<td style="padding-right: 20px;">
<asp:Label ID="Label8" runat="server" Text="Tasa Pobreza:" class="innerControl"></asp:Label>
</td>
<td style="padding-right: 20px;">
<asp:TextBox ID="pobrTB" runat="server" class="innerControl" Width="70px" ></asp:TextBox>
<asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender4" runat="server"
FilterType="Numbers, Custom" ValidChars=".," TargetControlID="pobrTB">
</asp:FilteredTextBoxExtender>
</td>
<td>
%
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div class="popup" style="width: 601px;">
<table>
<tr>
<td align="center" colspan="6" class="style2">
<asp:Button ID="guardarNecesBTN" Text="Guardar" style="width: 110px;"
runat="server" onclick="guardarNecesBTN_Click" Visible="true"/>
<asp:Button ID="cerrarModBTN" Text="Cerrar" style="width: 110px;"
runat="server" onclick="closePopUp" Visible="false"/>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="Test" Text="" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
And this is the .cs codebehind
public partial class nueva_necesidad : System.Web.UI.Page
{
int fol = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
loadMeses();
loadAnos();
loadIntendencias();
String fec = DateTime.Today.Day.ToString();
fec = fec + "-" + DateTime.Today.Month.ToString();
fec = fec + "-" + DateTime.Today.Year.ToString();
fecTB.Text = (fec);
}
}
protected void loadIntendencias()
//Loads the intDDL with values taken from a DB table
{
intDDL.Items.Clear();
ListItem newItem = null;
List<entIntendencia> intList = new List<entIntendencia>();
intList = boNeces.loadIntendencias(Convert.ToInt32(Session["reg_usu"].ToString()), Convert.ToInt32(Session["niv_usu"].ToString()));
foreach (entIntendencia i in intList)
{
newItem = new ListItem();
newItem.Text = i.nombre;
newItem.Value = i.id_int.ToString();
intDDL.Items.Add(newItem);
}
}
protected void loadMeses()
//Loads the mesDDL, pre-selecting the (current month + 2) from the DDL
{
DateTime d = DateTime.Today;
int mesNum = d.Month;
ListItem newItem = null;
List<String> meses = new List<String>();
meses.Add("Enero");
meses.Add("Febrero");
meses.Add("Marzo");
meses.Add("Abril");
meses.Add("Mayo");
meses.Add("Junio");
meses.Add("Julio");
meses.Add("Agosto");
meses.Add("Septiembre");
meses.Add("Octubre");
meses.Add("Noviembre");
meses.Add("Diciembre");
for (int i = 0; i <= 11; i++)
{
newItem = new ListItem();
newItem.Text = meses[i];
newItem.Value = (i + 1).ToString();
mesDDL.Items.Add(newItem);
}
if (d.Month != 11 && d.Month != 12)
mesDDL.SelectedIndex = mesNum + 1;
else
{
if (d.Month == 11)
mesDDL.SelectedIndex = 0;
else
mesDDL.SelectedIndex = 1;
}
}
protected void loadAnos()
//Loads the anoDDL with a list of two: the current year and the next one.
{
anoDDL.Items.Clear();
DateTime d = DateTime.Today;
int ano = d.Year;
ListItem newItem = null;
List<int> list = new List<int>();
list.Add(ano);
list.Add(ano + 1);
foreach (int an in list)
{
newItem = new ListItem();
newItem.Text = an.ToString();
newItem.Value = an.ToString();
anoDDL.Items.Add(newItem);
}
}
protected bool validaNecesidad(out int inten, out int meses, out int mes, out int ano, out int pob)
//Validates the completion of the form's input fields.
{
inten = 0;
meses = 0;
mes = 0;
ano = 0;
pob = 0;
Test.Text = intDDL.SelectedValue.ToString() + mesesTB.Text; //This line is intended to load the values of one of the comboboxes and one of the input textboxes onto a label called "Test" that's on the form itself, to check if they do have values or not, this is the first instruction that executes when the save button is clicked.
if (!Int32.TryParse(intDDL.SelectedValue.ToString(), out inten))
{
Test.Text = Test.Text + "Error en DDL intendencia";
return false;
}
if (inten <= 0)
{
Test.Text = Test.Text + "Error en DDL intendencia";
return false;
}
if (!Int32.TryParse(mesesTB.Text, out meses))
{
Test.Text = Test.Text + "Error en TB meses";
return false;
}
if (meses <= 0)
{
Test.Text = Test.Text + "Error en TB meses";
return false;
}
if (!Int32.TryParse(mesDDL.SelectedValue, out mes))
{
Test.Text = Test.Text + "Error en DLL mes";
return false;
}
if (mes <= 0)
{
Test.Text = Test.Text + "Error en DLL mes";
return false;
}
if (!Int32.TryParse(anoDDL.SelectedValue, out ano))
{
Test.Text = Test.Text + "Error en DLL ano";
return false;
}
if (ano <= 0)
{
Test.Text = Test.Text + "Error en DLL ano";
return false;
}
if (!Int32.TryParse(pobTB.Text, out pob))
{
Test.Text = Test.Text + "Error en TB pob";
return false;
}
if (pob <= 0)
{
Test.Text = Test.Text + "Error en TB pob";
return false;
}
if (string.IsNullOrWhiteSpace(empTB.Text))
{
Test.Text = Test.Text + "Error en TB emp";
return false;
}
if (string.IsNullOrWhiteSpace(pobrTB.Text))
{
Test.Text = Test.Text + "Error en TB pobr";
return false;
}
if (string.IsNullOrWhiteSpace(fundTB.Text))
{
Test.Text = Test.Text + "Error en TB fund";
return false;
}
return true;
}
protected void guardarNecesBTN_Click(object sender, EventArgs e)
//Saves a new record on the NECESIDADES table.
{
int res = 0;
int inten = 0;
int meses = 0;
int mes = 0;
int ano = 0;
int pob = 0;
if (validaNecesidad(out inten, out meses, out mes, out ano, out pob))
{
res = boNeces.saveNeces(inten, meses, mes, ano, pob, empTB.Text, pobrTB.Text, fundTB.Text, Session["log_usu"].ToString());
if (res != 0)
{
Test.Text = Test.Text + "Folio creado correctamente con el N° " + res + ".";
Test.ForeColor = System.Drawing.Color.Green;
guardarNecesBTN.Visible = false;
cerrarModBTN.Visible = true;
intDDL.SelectedIndex = 0;
loadMeses(); loadAnos();
empTB.Text = ""; pobTB.Text = ""; pobrTB.Text = ""; fundTB.Text = "";
}
else
{
Test.Text = "Ha ocurrido un problema, favor intentar más tarde.";
Test.ForeColor = System.Drawing.Color.Gray;
guardarNecesBTN.Visible = false;
cerrarModBTN.Visible = true;
intDDL.SelectedIndex = 0;
loadMeses(); loadAnos();
empTB.Text = ""; pobTB.Text = ""; pobrTB.Text = ""; fundTB.Text = "";
}
}
else
{
Test.Text = Test.Text + "Faltan campos por completar.";
Test.ForeColor = System.Drawing.Color.Red;
}
}
protected void closePopUp(object sender, EventArgs e)
//Function used to call the JavaScript function that closes the modal popup.
{
ScriptManager.RegisterStartupScript(this, GetType(), "closeMod", "closeMod();", true);
}
}
FINAL EDIT:
I've already solved the issue. It was because of the enable view state property set to false on the application's configuration under IIS manager. Changed it to true and now it works same as local.
First of all, add clearing of mesDDL dropdown in loadMeses() function.
Secondly, where is your sql-query? I didn't find that.

Dynamic grid on ASP.NET

I here to seek an advice ,what is the best approach.
here is the scenario.
I am building my project ASP.NET (C#)
I need to add an dynamic drop down box based on that two other text box related to drop down.
for example :
I have a button called "ADD LANDSCAPE", every time this triggered, i have to create an dynamic drop down "ddlLandscap" and two text boxes so the user can enter landscape value for each text box.
Can you guys please advise what's the best approach
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="CS1.aspx.cs" Inherits="workout.CS1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<link href="../jquery/jquery-ui.css" rel="stylesheet" />
<script src="../jquery/jquery-1.12.0.js"></script>
<script src="../jquery/jquery-ui.js"></script>
<style type="text/css">
body {
font-family: Arial;
font-size: 10pt;
}
.table {
border: 1px solid #ccc;
border-collapse: collapse;
}
.table th {
background-color: #F7F7F7;
color: #333;
font-weight: bold;
}
.table th, .table td {
padding: 5px;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="gvCustomers1" CssClass="table" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Slno" ItemStyle-Width="50px" ItemStyle-CssClass="Slno">
<ItemTemplate>
<%# Eval("Slno") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name" ItemStyle-Width="150px" ItemStyle-CssClass="Name">
<ItemTemplate>
<%# Eval("Name") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Country" ItemStyle-Width="150px" ItemStyle-CssClass="Country">
<ItemTemplate>
<%# Eval("Country")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Option">
<ItemTemplate>
<asp:Button ID="lnkDelete" runat="server" Text="Delete" OnClientClick="Confirmationbox(this);" />
<asp:Button ID="btn_update" runat="server" Text="Update" OnClientClick="updateable(this);" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Button ID="btnNewUser" runat="server" Text="Add" OnClientClick="return false;" />
<asp:Button ID="Button1" Text="Submit" runat="server" OnClick="Submit" OnClientClick="formatData()" />
<br />
<div id="dialog-form" title="Create new user">
<p class="validateTips">All form fields are required.</p>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="width: 150px">Name:<br />
<asp:TextBox ID="txtName" runat="server" Width="140" Text="" />
</td>
<td style="width: 150px">Country:<br />
<asp:TextBox ID="txtCountry" runat="server" Width="140" Text="" />
</td>
</tr>
</table>
</div>
<div id="dialog-form-edit" title="Edit user">
<p class="validateTips">All form fields are required.</p>
<asp:HiddenField ID="hdslno" runat="server" Value="" />
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="width: 150px">Name:<br />
<asp:TextBox ID="TextBox1" runat="server" Width="140" Text="" />
</td>
<td style="width: 150px">Country:<br />
<asp:TextBox ID="TextBox2" runat="server" Width="140" Text="" />
</td>
</tr>
</table>
</div>
<br />
<script type="text/javascript">
var dialog,editDialog;
function formatData() {
var formatdata = "";
$( '#gvCustomers1 tr:gt(0)' ).each( function () {
$( this ).find( 'td' ).each( function () {
if ( $( this ).hasClass( "Slno" ) || $( this ).hasClass( "Name" ) || $( this ).hasClass( "Country" ) ) {
formatdata += $( this ).html() + "|";
}
} );
formatdata += ",";
} );
alert( formatdata );
return false;
}
$(function () {
dialog = $("#dialog-form").dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Create an account": AddRow,
Cancel: function () {
dialog.dialog("close");
}
},
close: function () {
$("#txtName").val("");
},
open: function () {
var nr = $('#dialog-form').data('param');
if (nr) {
$("#txtName").val(nr);
} else {
$("#txtName").val("");
}
}
});
editDialog = $("#dialog-form-edit").dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Create an account": UpdateRow,
Cancel: function () {
editDialog.dialog("close");
}
},
close: function () {
$("#txtName").val("");
},
open: function () {
var nr = $('#dialog-form-edit').data('param');
console.log(nr);
$( "#hdslno" ).val( nr.slno );
$("#TextBox1").val(nr.name);
$("#TextBox2").val(nr.country);
}
});
});
$("#btnNewUser").button().on("click", function () {
dialog.dialog("open");
});
function Confirmationbox(obj) {
if (confirm("Do you want to delete this Customer?")) {
var row = $(obj).closest("tr");
row.remove();
}
return true;
}
function updateable(obj) {
var row = $(obj).closest("tr");
var slno = $(row).find("td").eq(0).html();
var name = $(row).find("td").eq(1).html();
var country = $(row).find("td").eq(2).html();
try {
var json = {
slno: slno,
name: name,
country: country
};
editDialog.data('param', json).dialog("open");
event.preventDefault();
} catch (e) {
alert(e);
}
return false;
}
function UpdateRow() {
var slno = $( "#hdslno" ).val();
var m_Name = $( "#TextBox1" ).val();
var m_Country = $( "#TextBox2" ).val();
var row = null;
$( '#gvCustomers1 tr:gt(0)' ).each( function () {
$( this ).find( 'td' ).each( function () {
if ( $( this ).hasClass( "Slno" ) && $( this ).html() == slno ) {
row = $( this ).closest( "tr" );
}
} )
} );
if ( row ) {
$( row ).find( "td" ).eq( 1 ).html( m_Name );
$( row ).find( "td" ).eq( 2 ).html( m_Country );
}
editDialog.dialog( "close" );
return false;
}
function AddRow() {
//Reference the GridView.
var gridView = document.getElementById("<%=gvCustomers1.ClientID %>");
//Reference the TBODY tag.
var tbody = gridView.getElementsByTagName("tbody")[0];
//Reference the first row.
var row = tbody.getElementsByTagName("tr")[1];
//Check if row is dummy, if yes then remove.
if (row.getElementsByTagName("td")[0].innerHTML.replace(/\s/g, '') == "") {
tbody.removeChild(row);
}
//Clone the reference first row.
row = row.cloneNode(true);
var legnth = gridView.rows.length;
SetValue1(row, 0, "Slno", legnth);
//Add the Name value to first cell.
var txtName = document.getElementById("<%=txtName.ClientID %>");
SetValue(row, 1, "name", txtName);
//Add the Country value to second cell.
var txtCountry = document.getElementById("<%=txtCountry.ClientID %>");
SetValue(row, 2, "country", txtCountry);
//Add the row to the GridView.
tbody.appendChild(row);
dialog.dialog("close");
return false;
}
function SetValue(row, index, name, textbox) {
row.cells[index].innerHTML = textbox.value;
textbox.value = "";
}
function SetValue1(row, index, name,leng) {
row.cells[index].innerHTML = leng;
}
</script>
<asp:HiddenField ID="hdTableValues" runat="server" Value="" />
</form>
</body>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace workout
{
public partial class CS1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindGrid();
}
}
private void BindGrid()
{
DataTable dt = new DataTable();
string query = "SELECT '' Slno, Name, Country FROM dd_Detils";
string constr = "Data Source=localhost;Initial Catalog=DataBase;User ID=sa;Password=globalfocus";
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.Connection = con;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
sda.SelectCommand = cmd;
sda.Fill(dt);
}
}
}
if (dt.Rows.Count == 0)
{
//If no records then add a dummy row.
dt.Rows.Add();
}
gvCustomers1.DataSource = dt;
gvCustomers1.DataBind();
}
protected void Submit(object sender, EventArgs e)
{
int cnt = gvCustomers1.Rows.Count;
if (!string.IsNullOrEmpty(Request.Form["name"]) && !string.IsNullOrEmpty(Request.Form["country"]))
{
//Fetch the Hidden Field values from the Request.Form collection.
string[] names = Request.Form["name"].Split(',');
string[] countries = Request.Form["country"].Split(',');
//Loop through the values and insert into database table.
for (int i = 0; i < names.Length; i++)
{
string constr = "Data Source=localhost;Initial Catalog=Database;User ID=sa;Password=globalfocus";
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO dd_Detils VALUES(#Name, #Country)"))
{
cmd.Parameters.AddWithValue("#Name", names[i]);
cmd.Parameters.AddWithValue("#Country", countries[i]);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
//Refresh the page to load GridView with records from database table.
Response.Redirect(Request.Url.AbsoluteUri);
}
}
}
}

How to display a dynamically created DIV next to another?

I am creating a page that will display log files on a page dynamically as they are created. Here is my front end:
<div id="container">
<asp:UpdatePanel UpdateMode="Conditional" runat="server" ID="ServerUpdates">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
Here is my css:
#container {
width:100%;
display: inline-block;
height:100%;
}
.textboxStatus
{
/*background-image:url('http://placehold.it/15/15');*/
background-repeat:no-repeat;
/* background-position:3px 3px;*/
border:solid 1px black;
padding:20px;
width:600px;
height:500px;
float:left;
clear:left;
/*position:relative;*/
}
/*.textbox input
{
border:none;
background:transparent;
width:100%;
outline: none;
}*/
.textboxURL
{
/*background-image:url('http://placehold.it/15/15');*/
background-repeat:no-repeat;
/* background-position:3px 3px;*/
border:solid 1px black;
padding:20px;
width:575px;
height:475px;
float:right;
/*clear: right;
position:relative;*/
display:inline;
}
Here is my code behind:
protected void CreateDiv(object sender, EventArgs e)
{
string path = #"\\server\d$\websites\Updates\Product\Production\Logs";
//int rowCount = 0;
DirectoryInfo dir = new DirectoryInfo(path);
List<FileInfo> FileList = dir.GetFiles().ToList();
ServerUpdates.ContentTemplateContainer.Controls.Add(new LiteralControl("<asp:GridView runat='server' ID='Grid' AutoGenerateColumns='false'>"));
ServerUpdates.ContentTemplateContainer.Controls.Add(new LiteralControl("<Columns>"));
foreach (FileInfo file in FileList)
{
StreamReader sr = new StreamReader(new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
// string[] findStatus = System.IO.Directory.Exists(path, "codepush.log.*", System.IO.SearchOption.TopDirectoryOnly);
// string[] findURL = System.IO.Directory.GetFiles(path, "sql.output.log.*", System.IO.SearchOption.TopDirectoryOnly);
bool findStatus = (file.Name.Contains("codepush.log.")) ? true : false;//File.Exists(Path.Combine(path, ".txt"));
bool findURL = (file.Name.Contains("sql.output.")) ? true : false;
if (findStatus == true)
{
//ServerUpdates.ContentTemplateContainer.Controls.Add(new LiteralControl(String.Format("<br /><div class=\"statusLog\"><asp:TextBox runat=\"server\" id=\"tbStatus{0}\"/> </div><div class=\"urlLog\"></div>", count)));
//(TextBox)ServerUpdates.ContentTemplateContainer.FindControl("tbStatus" + count.ToString());
ServerUpdates.ContentTemplateContainer.Controls.Add(new LiteralControl(string.Format("<asp:BoundField Datafield={0} /><div class='textboxStatus'>", rowCount)));
TextBox txt = new TextBox();
txt.TextMode = TextBoxMode.MultiLine;
txt.Wrap = false;
txt.Width = 600;
txt.Height = 500;
while (!sr.EndOfStream)
txt.Text = txt.Text + sr.ReadLine() + "\r\n";
//Panel txt = new Panel();
//txt.ScrollBars = ScrollBars.Vertical;
//txt.Wrap = true;
ServerUpdates.ContentTemplateContainer.Controls.Add(txt);
ServerUpdates.ContentTemplateContainer.Controls.Add(new LiteralControl("</div>"));
ServerUpdates.ContentTemplateContainer.Controls.Add(new LiteralControl("</Columns>"));
}
if (findURL == true)
{
//ServerUpdates.ContentTemplateContainer.Controls.Add(new LiteralControl(String.Format("<br /><div class=\"statusLog\"><asp:TextBox runat=\"server\" id=\"tbStatus{0}\"/> </div><div class=\"urlLog\"></div>", count)));
//(TextBox)ServerUpdates.ContentTemplateContainer.FindControl("tbStatus" + count.ToString());
ServerUpdates.ContentTemplateContainer.Controls.Add(new LiteralControl("<Columns>"));
ServerUpdates.ContentTemplateContainer.Controls.Add(new LiteralControl(string.Format("<asp:BoundField Datafield={0} /><div class='textboxURL'>", rowCount)));
TextBox txt = new TextBox();
txt.TextMode = TextBoxMode.MultiLine;
txt.Wrap = false;
txt.Width = 575;
txt.Height = 475;
while (!sr.EndOfStream)
txt.Text = txt.Text + sr.ReadLine() + "\r\n";
//Panel txt = new Panel();
//txt.ScrollBars = ScrollBars.Vertical;
//txt.Wrap = true;
ServerUpdates.ContentTemplateContainer.Controls.Add(txt);
ServerUpdates.ContentTemplateContainer.Controls.Add(new LiteralControl("</div>"));
ServerUpdates.ContentTemplateContainer.Controls.Add(new LiteralControl("</Columns>"));
}
//rowCount++;
}
ServerUpdates.ContentTemplateContainer.Controls.Add(new LiteralControl("</asp:GridView>"));
}
My issue is that it is not displaying the URL div next to the first Status div and so fourth. The URL div displays last.
I need it to display the URL div next to the Status div for each div (file).
I have been trying GridView so any suggestions would be helpful.
I am not sure I understand the problem, but to your issue " it is not displaying the URL div next to the first Status div and so fourth. The URL div displays last," I recommend the following:
<div class="row">
<div class="textboxStatus">
</div>
<div class="textboxURL">
</div>
</div>
Apply float: left; to both textboxStatus and textboxURL. I understand, this is dynamically generated, but instead, why not AJAX to fetch the content and then simply fill it?
You can easily use AJAX with webforms like so:
http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
In your ".textboxStatus" css-class you have defined a "float:left" and are clearing the float at the same time with "clear:left".
Remove both attributes and in ".textboxURL" replace "float:right" with "float:left" and you should be fine.
first we will define the main div or body in which other will be contained for that div the style will be
#maindiv{
width: 100%;
font-size: 12px;
overflow: hidden;
background: #ccc
}
in your case it will be "container"
now when you are adding the divs as
then first div style will be
#leftdiv {
float: left;
width: 33%;
background-color: #bbb;
}
after that set the width of each div and put the width to the style of that d
#nextdiv {
float: left;
background-color: #eee;
width: 33%;
}
and so on..
You should generate a <TABLE> with one line <TR> and multiple columns <td> instead of generating an Asp.net Gridview control by Literal controls.
Remember to write Html tags when you use Literal controls
Example of final html:
<Table>
<tr>
<td>First div inside</td>
<td>Second div inside</td>
...
</tr>
</Table>

Categories