Click here to Skip to main content
15,900,907 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello I am developing one application in that I take gridview in page,i generated the dynamic textbox and I bind the calender extender through coding,but it did not work help me

the design code is following
XML
 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                    BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
                    CellPadding="3" CellSpacing="2"
                    onselectedindexchanging="GridView1_SelectedIndexChanging"
                    DataKeyNames="event_id"
                    onselectedindexchanged="GridView1_SelectedIndexChanged"
                    onrowupdating="GridView1_RowUpdating" onrowediting="GridView1_RowEditing">
                    <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
                <Columns>
                    <asp:TemplateField>
                    &lt;HeaderTemplate>
                    Event Id
                    &lt;/HeaderTemplate>
                    <ItemTemplate>
                    <asp:Label ID="lbl1" Text='<%#Eval("event_id") %>' runat="server">
                    </asp:Label></ItemTemplate></asp:TemplateField>
                    <asp:TemplateField>
                    &lt;HeaderTemplate>
                    Event name
                    &lt;/HeaderTemplate>
                    <ItemTemplate>
                    <asp:Label ID="lbl" Text='<%#Eval("event_name") %>' runat="server">
                    </asp:Label></ItemTemplate></asp:TemplateField>
                    <%--<asp:TemplateField HeaderText="Event time">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%#Eval("event_date") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>--%>
                    <asp:BoundField DataField="event_date" HeaderText="Event Date" />
                    <asp:CommandField ShowEditButton="True" />
                    <asp:CommandField ShowDeleteButton="True" />
                </Columns>
                    <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
                    <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                    &lt;SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
                    &lt;HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
                </asp:GridView>






The coding is following

I add the namespace using AjaxControlToolkit;


TextBox txt_box=new TextBox();
        txt_box.ID="txt_date";
       //txt_box=(TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0];
     AjaxControlToolkit.CalendarExtender cal_date = new AjaxControlToolkit.CalendarExtender();
       cal_date.ID = "cal_date";
       cal_date.Format = "dd-mm-yyyy";
       cal_date.TargetControlID = txt_box.ID;
       GridView1.Controls.Add(txt_box);
       GridView1.Controls.Add(cal_date);
Posted
Updated 21-Jun-13 23:48pm
v3
Comments
Mahesh Bailwal 22-Jun-13 5:46am    
what error you are getting?

1 solution

Hi Krupali,
As per your post I understood that you are trying create textbox dynamically and bind the calendar extendar to it.Below are two links which can help you to resolve your problem.
http://stackoverflow.com/questions/17052397/add-ajax-calendarextender-to-a-dynamic-textbox-in-asp-net-c-sharp[^]
http://stackoverflow.com/questions/6533247/ajax-control-toolkit-calendar-for-dynamically-generated-textboxes[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900