Solved

How to add ajax calendar in gridview dynamically

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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