Solved

How to add ajax calendar in gridview dynamically

Posted on 2013-12-16
2
1,588 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 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