p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: ASP.NET 4 Website Programming Problem Design Solution (http://p2p.wrox.com/forumdisplay.php?f=540)
-   -   Display image in gridview according to selected date of user (http://p2p.wrox.com/showthread.php?t=87163)

KnightErrant April 3rd, 2012 02:22 AM

Display image in gridview according to selected date of user
 
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox>

<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1">
</asp:CalendarExtender>

</div>


using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
public partial class View : System.Web.UI.Page
{
string strcon = ConfigurationManager.ConnectionStrings["con"].ToString();

protected void Page_Load(object sender, EventArgs e)
{
string str = TextBox1.Text;

CultureInfo[] cultures = { CultureInfo.CreateSpecificCulture("en-US") };
foreach (CultureInfo culture in cultures)
{
DateTime date;
date = DateTime.Parse(str, culture);
}
//string str = TextBox1.Text;
// DateTime date = DateTime.ParseExact(str, "yyyy/MM/DD", null);
//System.DateTime str_date = DateTime.Parse(TextBox1.Text, System.Globalization.CultureInfo.CreateSpecificCul ture("en-AU").DateTimeFormat);
//var userdateformat = DateTime.ParseExact(" ' " + TextBox1.Text.ToString() + " ' ", "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);

Load_GridData();

}
void Load_GridData()
{
SqlConnection conn = new SqlConnection(strcon);
conn.Open(); // open the connection
SqlDataAdapter Sqa = new SqlDataAdapter("select Image, ImageName from Img where ([Date] = @date) ", conn);
DataSet ds = new DataSet();
Sqa.Fill(ds); // fill the dataset
GridView1.DataSource = ds; // give data to GridView
GridView1.DataBind();
conn.Close();
}
}


ERROR:- STRING IS NOT RECOGNIZED AS VALID DATETIME.[:confused:]
date is save in yyyy-mm-dd formate in database.

asimhazro April 23rd, 2016 03:36 AM

Display image in gridview according to selected date of user
 
Always use css to display images or contents in gird style from your database...
if size of your content displaying page is 900px then you fix size of each content close to 280px then your 3 images will come in single line....

<div style=" width:280px; height:300px; float:left; padding:10px;">
<?php
work with while loop and then you will get result
?>
</div>

for more get developers community


All times are GMT -4. The time now is 09:19 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.