Solved

How to add ajax calendar in gridview dynamically

Posted on 2013-12-16
2
1,504 Views
Last Modified: 2013-12-17
Hi there,

in my gridview i have some textboxes in each row.

on row data bound  I want to display an ajaax calendar with the textbox if the a template field contains the value date.

for example
if (isDate == "Date")
            {
               
                AjaxControlToolkit.CalendarExtender CalBolton = new AjaxControlToolkit.CalendarExtender();
                CalBolton.ID = "calBolton" + i;
                CalBolton.Format = "dd/MM/yyyy";
                CalBolton.TargetControlID = txtBoltonCCG.ID;
                grdStandsrds.Controls.Add(CalBolton);
                i = i + 1;
            }

kind regards,
0
Comment
Question by:shah36
2 Comments
 
LVL 20

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
ID: 39721381
It's not completely clear what your question is. However, I will do what I can to answer this the best I can.

First off, you are going to do this in the GridView RowDataBound event, right?

Secondly, you are going to work with RowData such that in the event, e:

e.Row.RowType == DataControlRowType.DataRow, right?

Third, you are going to grab the the cells in this fashion:

TableCell myCell = e.Row.Cells[0];

Each cell will be indexed 0...whatever being the number of columns you have in the row. Therefore, Column 0 would be e.Row.Cells[0] and Column 1 would be e.Row.Cells[1], etc.

You'd need to find the column for your calendar: e.Rows.Cells9x] where x is the column for the textbox with the date in it.

Then, you'd build your calendar control, like you already are doing. Then, you's simply add it to the column:

e.Row.Cells[x].Controls.Add(myCalendarControl);

Or, if you do like I do, first:

TableCell startDateCell = e.Row.Cells[x];
startDateCell.Controls.Add(myCalendarControl);

works too.

You do this within the RowDataBound event for each and every column.
0
 

Author Closing Comment

by:shah36
ID: 39723551
Thank you so much. It worked like a charm.

regards,
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Auto refresh part of an MVC5 View 7 61
ADO.NET ENTITY DATA MODEL 3 32
ASP.NET 5 Templates 2 66
User Authentication using Digital Certificate 2 26
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now