473,395 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to retrieve data in gridview according to date selected by user

Expand|Select|Wrap|Line Numbers
  1.  
  2. <asp:ScriptManager ID="ScriptManager1" runat="server">
  3. </asp:ScriptManager>
  4. <div>
  5. <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox>
  6.  
  7. <asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1">
  8. </asp:CalendarExtender>
  9.  
  10. </div>
  11.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Configuration;
  5. using System.Data;
  6. using System.Data.OleDb;
  7. using System.Data.SqlClient;
  8. using System.Linq;
  9. using System.Web;
  10. using System.Web.UI;
  11. using System.Web.UI.WebControls;
  12. using System.Globalization;
  13. public partial class View : System.Web.UI.Page
  14. {
  15. string strcon = ConfigurationManager.ConnectionStrings["con"].ToString();
  16.  
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. string str = TextBox1.Text;
  20.  
  21. CultureInfo[] cultures = { CultureInfo.CreateSpecificCulture("en-US") };
  22. foreach (CultureInfo culture in cultures)
  23. {
  24. DateTime date;
  25. date = DateTime.Parse(str, culture);
  26. }
  27. //string str = TextBox1.Text;
  28. // DateTime date = DateTime.ParseExact(str, "yyyy/MM/DD", null);
  29. //System.DateTime str_date = DateTime.Parse(TextBox1.Text, System.Globalization.CultureInfo.CreateSpecificCulture("en-AU").DateTimeFormat);
  30. //var userdateformat = DateTime.ParseExact(" ' " + TextBox1.Text.ToString() + " ' ", "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
  31.  
  32. Load_GridData();
  33.  
  34. }
  35. void Load_GridData()
  36. {
  37. SqlConnection conn = new SqlConnection(strcon);
  38. conn.Open(); // open the connection 
  39. SqlDataAdapter Sqa = new SqlDataAdapter("select Image, ImageName from Img where ([Date] = @date) ", conn);
  40. DataSet ds = new DataSet();
  41. Sqa.Fill(ds); // fill the dataset 
  42. GridView1.DataSource = ds; // give data to GridView
  43. GridView1.DataBind();
  44. conn.Close();
  45. }
  46. }
  47.  
ERROR:- STRING IS NOT RECOGNIZED AS VALID DATETIME..


date is saved in yyyy-mm-dd formate in database. Please help.
Apr 3 '12 #1
0 1930

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Claudia Fong | last post by:
Hi, I have a form where I need to display the data of a department that stores in a access db. When I first load the form it will call a function name loaddata which will get the first...
1
by: funcSter | last post by:
I want to retrieve data from an Excel file like how I would with a database. I understand that I would have to use OLE DB. Somehow I think I cannot get the connection string right, as the bit of...
5
by: ggk517 | last post by:
We are trying to develop an Engineering application using PHP, Javascript with Informix as the back-end. Is it possible to retrieve data using Javascript but by accessing the Database. Say...
11
by: AishaKhalfan | last post by:
Hi all, I have to populate combo box that retrieve data from database in windows based application. I have two tables which are type and CD. Type has type ID and Category. CD has type ID as...
1
by: sambathrajmca | last post by:
Hai, I am sambath Raj.I am new for you.Now i am trying to use windows forms with data GridView Controll.Now i am adding combobox in that data GridView but defaultly New Row Will be added next to...
2
by: ganesandeiav | last post by:
Dear sir how to retrieve a data that has been selected using combo box using jsp
1
by: suffolkmike | last post by:
Hello, I am currently building a daily reporting log for my company. A user will input data into a form, the form then stores on the database, another user will sign on to view the data from the...
1
by: dotnetnovice | last post by:
Hi everybody... I want to show data in the data gridview placed in my form after getting data from my data access layer class through a class... Here is my code in the data access layer class....
0
by: lenniekuah | last post by:
Hi Friends, I need your help. Please help me. I am trying to retrieve data from Excel Spreadsheet to fill the DataGridView for display prior to updating SQL SERVER with individual DataGridView...
1
by: Nilesh K R | last post by:
hello, I am try to retrieve data from my c# windows application to excel sheet and store this .xls file to desired location. but my problem is that my code save excel file at a predefined location....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.