Asp.net
Loading
Asp.net
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit MohantyRank #112 · 20K reputationPosted Mar 21, 2024, 8:30 AM EDT
Hey Mood Sanjeev Kumar, Before you ask your question, could you please check the Forums Posting Guidelines?
https://www.c-sharpcorner.com/Forums/MustRead.aspx
Simran VermaRank #831 · 2.7K reputationPosted Mar 21, 2024, 8:30 AM EDT
To implement a datepicker within a GridView in ASP.NET, you can follow these steps:
Add GridView to your ASP.NET Page: Define a GridView control in your ASP.NET page where you want to display the data.
Define Columns: Define the columns for your GridView. For the column where you want to have a datepicker, you'll need to use a TemplateField.
Add a TemplateField for Datepicker: In the TemplateField, you can place an input control of type "text" and attach a datepicker control to it.
Here's an example of how you can achieve this:
Attach Datepicker JavaScript: In your ASP.NET page, you can attach a JavaScript function that initializes the datepicker control. You might use libraries like jQuery UI for this purpose.
With this setup, when your GridView renders, any textboxes with the "datepicker" class will automatically get converted into datepicker controls by jQuery UI.
Remember to include necessary CSS and JavaScript files for jQuery and jQuery UI, and adjust them based on your project structure and requirements.
This is a basic implementation. You may need to handle more complex scenarios like date formatting, date validation, and so on, depending on your specific requirements.
Vishal YelveRank #178 · 13.6K reputationPosted Mar 21, 2024, 9:49 AM EDT
$(document).ready(function () { $("[id$=txtEndDate]").datepicker({ dateFormat: "dd/mm/yy", }); });protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[8] { new DataColumn("Emp_Id_R", typeof(int)), new DataColumn("Approved", typeof(string)), new DataColumn("DisLike", typeof(string)), new DataColumn("Delay", typeof(string)), new DataColumn("Deny", typeof(string)), new DataColumn("VIN", typeof(string)), new DataColumn("Post_Status", typeof(string)), new DataColumn("End_Date", typeof(DateTime)) }); dt.Rows.Add(1, "Approved", "Dislike1", "Delay1", "Deny1", "VIN1", "Post_Status1", "01-01-2017"); dt.Rows.Add(2, "Approved", "Dislike2", "Delay2", "Deny2", "VIN2", "Post_Status2", "02-01-2017"); dt.Rows.Add(3, "Approved", "Dislike3", "Delay3", "Deny3", "VIN3", "Post_Status3", "03-01-2017"); gvStatusTotal.DataSource = dt; gvStatusTotal.DataBind(); } }