|
|
|
|
|
#1 -
16/03/2009 12:19:57
|
Reporta abuso
|
Link Permanente
|
|
Problema para mostrar una fecha
|
|
|
|
|
|
Hola a todos, tengo un gran problema, estoy haciendo una consulta desde SQL, la idea es mostrar en la tabla los datos de las fotografías, todos salen bien , excepto la fecha, no puedo convertir un string en DateTime, necesito que me ayuden, es urgente porfavor, a continuación les dejo el código:
namespace EzRoute { /// <summary> /// Summary description for SelectedMerchandising. /// </summary>
public partial class SelectedMerchandising : System.Web.UI.Page { protected System.Web.UI.HtmlControls.HtmlTable table; protected void Page_Load(object sender, System.EventArgs e) { if ( !this.IsPostBack ) { String salespersonID = Session["SalesPersonID"].ToString(); String fromDate = Session["FromDate"].ToString(); String toDate = Session["ToDate"].ToString();
Session.Remove( "SalesPersonID" ); Session.Remove( "FromDate" ); Session.Remove( "ToDate" ); string connectionString = (string)System.Configuration.ConfigurationManager.ConnectionStrings["MsrEzrConnectionString"].ConnectionString; SqlConnection Con = new SqlConnection(connectionString);
Con.Open(); SqlCommand cmd = new SqlCommand(@"SELECT merchandising.ROWID, merchandising.CustomerID, merchandising.Notes, customersmaster.customername, merchandising.PictureLogged FROM Merchandising, customersmaster where customersmaster.customerid = Merchandising.customerid and " + @"SalespersonID = '"+salespersonID+"' AND PictureLogged BETWEEN '"+fromDate+"' "+ @"AND '"+toDate+"'", Con );
SqlDataReader dr = cmd.ExecuteReader(); Int32 rowid = -1; int irow = 0;
while( dr.Read() ) { rowid = dr.GetInt32(0);
HtmlTableRow row = new HtmlTableRow();
if ( irow % 2 == 0 ) row.BgColor = "#ff0000"; else row.BgColor = "#0000ff"; // Adding the picture part HtmlTableCell cell = new HtmlTableCell(); cell.InnerHtml = "<img src=\"DisplayBeforeNAfter.aspx?ImgID=1&height=320&width=240&rowid="+rowid+"\">"; row.Cells.Add( cell ); cell = new HtmlTableCell(); cell.InnerHtml = "<img src=\"DisplayBeforeNAfter.aspx?ImgID=2&height=320&width=240&rowid="+rowid+"\">"; row.Cells.Add( cell ); Table1.Rows.Add( row );
// Add simple Text row = new HtmlTableRow(); cell = new HtmlTableCell(); cell.InnerText = "Before"; row.Cells.Add( cell ); cell = new HtmlTableCell(); cell.InnerText = "After"; row.Cells.Add( cell ); Table1.Rows.Add( row ); // Add Customerid Text
row = new HtmlTableRow(); cell = new HtmlTableCell(); if ( dr.IsDBNull(1) ) cell.InnerText = "Customerid"; else cell.InnerText = dr.GetString(1); row.Cells.Add( cell ); cell = new HtmlTableCell(); if ( dr.IsDBNull(2) ) cell.InnerText = "CustomerName"; else cell.InnerText = dr.GetString(2); row.Cells.Add( cell ); Table1.Rows.Add( row );
//Add Customer Info row = new HtmlTableRow(); cell = new HtmlTableCell(); if (dr.IsDBNull(3)) cell.InnerText = "Notes"; else cell.InnerText = dr.GetString(3); row.Cells.Add(cell); //Add Date Info cell = new HtmlTableCell();
if (dr.IsDBNull(4)) cell.InnerText = "PictureLogged"; else DateTime.Parse("cell"); cell.InnerText = dr.GetDateTime(4); ----:: Este es el problema. AYUDA row.Cells.Add(cell);
row.Cells.Add(cell); Table1.Rows.Add(row);
irow++; } } }
#region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() {
} #endregion } }
|
|
|
|
|