Solved

How to add ajax calendar in gridview dynamically

Posted on 2013-12-16
2
1,528 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 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