none
Gridview jquery multi datepicker not getting values RRS feed

  • Question

  • Hello All,

    I have implemented a dynamic gridview with dynamic rows at runtime.. place an 2 textbox in every gridviewrow. One Textbox as textbox and Two Textbox i bind an datepicker using jquery. Every thing was working fine dynamic genaration of gridrow wtih textbox and textbox(datepicker).

    user enter values in textbox and select date from datepicker, when user click on save button textbox valeus getting, while datepicker textbox values remains null..

    myCode:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
        type="text/javascript"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
        rel="Stylesheet" type="text/css" />
    <script type="text/javascript">
        $(function () {
            $("[id$=txtDate]").datepicker({
                showOn: 'button',
                buttonImageOnly: true,
                buttonImage: 'http://jqueryui.com/demos/datepicker/images/calendar.gif'
            });

            $("[id$=txtDate]").each(function () {
                $(this).datepick({ dateFormat: 'dd MM yyyy' });
            });

     

        });
    </script>

    <asp:GridView ID="Gridview1" runat="server" ShowFooter="true" AutoGenerateColumns="false"
                                OnSelectedIndexChanged="Gridview1_SelectedIndexChanged" OnDataBound="Gridview1_DataBound"
                                OnRowCreated="Gridview1_RowCreated">
                                <Columns>
                                    <asp:BoundField DataField="RowNumber" HeaderText="PHASE NO" />
                                    <asp:TemplateField HeaderText="AMOUNT">
                                        <ItemTemplate>
                                            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                            <asp:RegularExpressionValidator runat="server" ID="valNumbersOnly" ControlToValidate="TextBox1"
                                                Display="Dynamic" ErrorMessage="Please enter a number only." ValidationExpression="(^([0-9]*|\d*\d{1}?\d*)$)">
                                            </asp:RegularExpressionValidator>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="TextBox1"
                                                runat="server" ErrorMessage="Column can't be blank."></asp:RequiredFieldValidator>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="DATE">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>

    :::::

    ::::

    for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
                                            {
                                                TextBox box1 = (TextBox)Gridview1.Rows[rowIndex].Cells[1].FindControl("TextBox1");
                                                getTextBx = box1.Text.ToString();
                                                aList.Add(getTextBx);

    // HERE IM GETTING NULL VALUES

                                                TextBox box2 = (TextBox)Gridview1.Rows[rowIndex].Cells[2].FindControl("txtDate");                                           
                                                getDateBx = box2.Text.ToString();
                                                aList.Add(getDateBx);

    how can achive this..

    any other way to achive the above functionality..


    NS

    Friday, May 17, 2013 5:01 AM

Answers

All replies