validation happening in Edit mode..

validation occuring in the controls outside the datagrid .

Actually, i have a datagrid on the same page where am am doin edit function . aftr making changes when clicked update button , am finding validations which r occurin in other controls on that page . which should not happen ...

Thanks ..Lukin for help...
<table class="main_tbl" style="left: 23px; position: relative; top: 49px; z-index: 102;">
            <tr>
                <td style="width: 100px">
                    Select City</td>
                <td style="width: 100px">
                    <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
                        DataTextField="city" DataValueField="cid" Style="position: relative" Width="110px" AppendDataBoundItems="True">
                        <asp:ListItem Value="ci">Select City</asp:ListItem>
                    </asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:tonivtreepConnectionString %>"
                        SelectCommand="SELECT [cid], [city] FROM [citytable]"></asp:SqlDataSource>
                </td>
                <td style="width: 100px">
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList1"
                        ErrorMessage="Select City" InitialValue="ci" Style="position: relative"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td style="width: 100px">
                    Enter Recipe<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                        ControlToValidate="TextBox1" ErrorMessage="*" Style="position: relative"></asp:RequiredFieldValidator></td>
                <td style="width: 100px">
                    <asp:TextBox ID="TextBox1" runat="server" Style="position: relative"></asp:TextBox></td>
                <td style="width: 100px">
                </td>
            </tr>
            <tr>
                <td style="width: 100px">
                </td>
                <td style="width: 100px">
                    &nbsp;<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/Add_Recipe.gif"
                        OnClick="ImageButton1_Click" Style="position: relative" /></td>
                <td style="width: 100px">
                    <asp:Label ID="Label1" runat="server" Style="position: relative" Width="69px"></asp:Label></td>
            </tr>
        </table>
        &nbsp;&nbsp;
        <asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="True"  AutoGenerateColumns="False"
            OnPageIndexChanged="DataGrid1_PageIndexChanged" Style="z-index: 103; left: 421px;
            position: absolute; top: 102px" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" OnCancelCommand="DataGrid1_CancelCommand" OnDeleteCommand="DataGrid1_DeleteCommand" OnEditCommand="DataGrid1_EditCommand" OnUpdateCommand="DataGrid1_UpdateCommand" DataKeyField="hid" >
            <Columns>
                <asp:BoundColumn DataField="city" HeaderText="City" ReadOnly="True"></asp:BoundColumn>
                <asp:TemplateColumn HeaderText="Recipe">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" Text='<%# Bind("recipe") %>' runat="server" Style="position: relative"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label2" Text='<%# Bind("recipe") %>' runat="server" Style="position: relative" ></asp:Label>
                    </ItemTemplate>
                </asp:TemplateColumn>
                <asp:EditCommandColumn CancelText="Cancel" EditText="Edit" HeaderText="Modify" UpdateText="Save">
                </asp:EditCommandColumn>
                <asp:ButtonColumn CommandName="Delete" Text="Delete"></asp:ButtonColumn>
            </Columns>
            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
            <SelectedItemStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
            <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" Mode="NumericPages" />
            <ItemStyle BackColor="White" ForeColor="#003399" />
            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
        </asp:DataGrid>

Open in new window

LVL 18
Rajar AhmedConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GreymanMSCCommented:
You do not have any ValidationGroup settings, so all validation happens at the page level.  There's no way to distinguish between items after all.

Set the ValidationGroup attribute on all controls, validators, and relevant command buttons to the same name.
0
keustermansCommented:
This will do the trick.

<asp:Button id=UpdateButton runat=server Text=Update CausesValidation=False />

Enjoy,
Marcus
0
kaylanreilorCommented:
If you want to quickly turn the validation off caused by other controls, set their CausesValidation property to false, like this button for example:
<asp:Button ID="btnTomorrow" runat="server" Text="Tomorrow"
        onclick="btnTomorrow_Click" CausesValidation=false />

Else, if you want to investigate further to understand what's occuring and if it has to do with your validator, let's set a custom error message with the ErrorMessage property of those validator. Thus in debug I suppose you'll be able to get a better idea of what's going on.
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

GreymanMSCCommented:
EG: Use MainGroup for the RequiredFieldValidators and ImageButton in the table, and DataGrid1Group for  the EditCommandColumn in the DataGrid.
<table class="main_tbl" style="left: 23px; position: relative; top: 49px; z-index: 102;">
            <tr>
                <td style="width: 100px">
                    Select City</td>
                <td style="width: 100px">
                    <asp:DropDownList ID="DropDownList1" runat="server"
                        DataSourceID="SqlDataSource1"
                        DataTextField="city" DataValueField="cid" 
                        Style="position: relative" Width="110px" 
                        ValidationGroup="MainGroup"
                        AppendDataBoundItems="True">
                        <asp:ListItem Value="ci">Select City</asp:ListItem>
                    </asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:tonivtreepConnectionString %>"
                        SelectCommand="SELECT [cid], [city] FROM [citytable]"></asp:SqlDataSource>
                </td>
                <td style="width: 100px">
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList1" ValidationGroup="MainGroup"
                        ErrorMessage="Select City" InitialValue="ci" Style="position: relative"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td style="width: 100px">
                    Enter Recipe<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                        ValidationGroup="MainGroup"
                        ControlToValidate="TextBox1" ErrorMessage="*" Style="position: relative"></asp:RequiredFieldValidator></td>
                <td style="width: 100px">
                    <asp:TextBox ID="TextBox1" runat="server" Style="position: relative"></asp:TextBox></td>
                <td style="width: 100px">
                </td>
            </tr>
            <tr>
                <td style="width: 100px">
                </td>
                <td style="width: 100px">
                    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/Add_Recipe.gif"
                        ValidationGroup="MainGroup"
                        OnClick="ImageButton1_Click" Style="position: relative" /></td>
                <td style="width: 100px">
                    <asp:Label ID="Label1" runat="server" Style="position: relative" Width="69px"></asp:Label></td>
            </tr>
        </table>
        &nbsp;&nbsp;
        <asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="True"  AutoGenerateColumns="False"
            OnPageIndexChanged="DataGrid1_PageIndexChanged" Style="z-index: 103; left: 421px;
            position: absolute; top: 102px" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" OnCancelCommand="DataGrid1_CancelCommand" OnDeleteCommand="DataGrid1_DeleteCommand" OnEditCommand="DataGrid1_EditCommand" OnUpdateCommand="DataGrid1_UpdateCommand" DataKeyField="hid" 
>
            <Columns>
                <asp:BoundColumn DataField="city" HeaderText="City" ReadOnly="True"></asp:BoundColumn>
                <asp:TemplateColumn HeaderText="Recipe">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" Text='<%# Bind("recipe") %>' runat="server" Style="position: relative"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label2" Text='<%# Bind("recipe") %>' runat="server" Style="position: relative" ></asp:Label>
                    </ItemTemplate>
                </asp:TemplateColumn>
                <asp:EditCommandColumn CancelText="Cancel" EditText="Edit" HeaderText="Modify" UpdateText="Save" ValidationGroup="DataGrid1Group">
                </asp:EditCommandColumn>
                <asp:ButtonColumn CommandName="Delete" Text="Delete"></asp:ButtonColumn>
            </Columns>
            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
            <SelectedItemStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
            <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" Mode="NumericPages" />
            <ItemStyle BackColor="White" ForeColor="#003399" />
            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
        </asp:DataGrid>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GreymanMSCCommented:
Ah, yes.  The EdotCommandColumn can be set to not cause validation.  Which, I guess, will be simpler unless you wish to add validation later.
<asp:EditCommandColumn CancelText="Cancel" EditText="Edit" 
    HeaderText="Modify" UpdateText="Save" CauseValidation="False">
</asp:EditCommandColumn>

Open in new window

0
Rajar AhmedConsultantAuthor Commented:
thanks for alllll........
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.