Click here to Skip to main content
15,892,199 members

Edit Item template retains its control

Hiral21 asked:

Open original thread
Hi all,

I have some critical problem with edit item template of gridview.

My aspx code for the girdview is like

XML
<asp:TemplateField HeaderText="T1" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <%-- <asp:Label ID="lblMonth1" Text='<%#Eval("Percentage1") %>' runat="server"></asp:Label>--%>
                        <asp:LinkButton ID="lblMonth1" Text='<%#Eval("Percentage1") %>' runat="server" OnClick="lblMonth_Click"></asp:LinkButton>
                        <asp:HiddenField ID="PeriodID1" runat="server" Value='<%#Eval("PeriodID1") %>' />
                        <asp:Label ID="date1" runat="server" Text='<%#Eval("date1","{0:d}") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox Width="70px" EnableCalendar="true" EnableShortDateCalendarString="true"
                            ID="datemonth1" CssClass="setting" runat="server" Text='<%#Eval("date1","{0:d}") %>'></asp:TextBox>
                        <ajaxToolkit:CalendarExtender ID="cal1" BehaviorID="bcal1" Enabled="true" PopupPosition="BottomRight"
                            TargetControlID="datemonth1" Format="dd/MM/yyyy" CssClass="font_strike" runat="server">
                        </ajaxToolkit:CalendarExtender>
                    </EditItemTemplate>
                    <ItemStyle HorizontalAlign="Center" Width="50px"></ItemStyle>
                </asp:TemplateField>                              
                <asp:CommandField ShowDeleteButton="false" ShowEditButton="true" DeleteText="Verwijder"
                    ItemStyle-BorderColor="Black" ItemStyle-ForeColor="Blue" EditText="Bewerk" CancelText="Annuleer"
                    UpdateText="Update"></asp:CommandField>
            </Columns>


I have made 10 cloumns same as the one datemonth1 in the table.
So i have 10 edit item templates in my page and I have set the calender control and all settings in gridview rowdata bound event..

If anyone need the code i can paste it here..

The flow in my page is


1)in the mainscreenpanel it shows a table based on the selection in the dropdowns
2)in the main screen panel i am providing a link button which shows second scrin in which i am showing the above gridview
3)now the problem is on clicking the edit link in the above table it works as i want but when I am not clicking on cancel link or update link,and directly press back button it shows main screen
4)and then again if i am clicking on the link button it shows the tables edititems.

How can i solve it..?
can any one help me..?
Tags: C# (C# 4.0)

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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