how to validation in editmode of datagrid

How to do validation while in edit mode in datagrid...??
<asp:DataGrid ID="DataGrid1" runat="server" AutoGenerateColumns="False" DataKeyField="fid"
            OnCancelCommand="DataGrid1_CancelCommand" OnDeleteCommand="DataGrid1_DeleteCommand" OnUpdateCommand="DataGrid1_UpdateCommand"
            OnEditCommand="DataGrid1_EditCommand" 
            Style="left: 24px; position: relative; top: 94px">
            <Columns>
                <asp:TemplateColumn HeaderText="City">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" Style="position: relative" DataSourceID="SqlDataSource1" DataTextField="city" DataValueField="cid" >
                        </asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:tonivtreepConnectionString2 %>"
                            SelectCommand="SELECT * FROM [citytable]"></asp:SqlDataSource>
                    </EditItemTemplate>
                    <ItemTemplate>
                       <asp:Label ID="Label1" runat="server" Style="position: relative" Text='<%# Bind("city") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateColumn>
                <asp:TemplateColumn HeaderText="recipe">
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Style="position: relative" Text='<%# Bind("recipe") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList2" runat="server" Style="position: relative" DataSourceID="SqlDataSource2" DataTextField="recipe" DataValueField="hid">
                        </asp:DropDownList><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:tonivtreepConnectionString3 %>"
                            SelectCommand="SELECT [hid], [recipe] FROM [recipetable]"></asp:SqlDataSource>
                    </EditItemTemplate>
                </asp:TemplateColumn>
                <asp:TemplateColumn HeaderText="restaurant">
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Style="position: relative" Text='<%# Bind("resname") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList3" runat="server" Style="position: relative" DataSourceID="SqlDataSource3" DataTextField="resname" DataValueField="rid">
                        </asp:DropDownList><asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:tonivtreepConnectionString %>"
                            SelectCommand="SELECT [rid], [resname] FROM [resttable]"></asp:SqlDataSource>
                    </EditItemTemplate>
                </asp:TemplateColumn>
                <asp:BoundColumn DataField="fname" HeaderText="Food"></asp:BoundColumn>
                <asp:BoundColumn DataField="ftype" HeaderText="FoodType"></asp:BoundColumn>
                <asp:BoundColumn DataField="fdesc" HeaderText="Description"></asp:BoundColumn>
                <asp:BoundColumn DataField="price" HeaderText="Price"></asp:BoundColumn>
                <asp:BoundColumn DataField="quantity" HeaderText="Quantity"></asp:BoundColumn>
                <asp:EditCommandColumn CancelText="Cancel" EditText="edit" HeaderText="Update" UpdateText="Save">
                </asp:EditCommandColumn>
                <asp:ButtonColumn CommandName="Delete" Text="Delete"></asp:ButtonColumn>
            </Columns>
        </asp:DataGrid>

Open in new window

LVL 18
Rajar AhmedConsultantAsked:
Who is Participating?
 
David RobitailleAnalyst ProgrammerCommented:
0
 
David RobitailleAnalyst ProgrammerCommented:
just but vlaidators between the <EditItemTemplate> tacg for eatch column you whant to valiadate

 
 
0
 
Rajar AhmedConsultantAuthor Commented:
nope ,

When it turms to edit mode on clicking edit button,
The validation should occur,in all bound columns..
Right now no need for edititemtemplate..columns....
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
David RobitailleAnalyst ProgrammerCommented:
well, you have to trun the BoundColumn into Template to add validators.
0
 
David RobitailleAnalyst ProgrammerCommented:
Why did i get a "B"
http://www.experts-exchange.com/help.jsp#hi403
"an answer is worth an A, unless it doesn't resolve your issue"
0
 
Rajar AhmedConsultantAuthor Commented:
hi, i had given the request to change it to A .I have no idea about this Grade n all . I had jst clicked something in a hurry at office .  
But really, these answer gave me some brisk thought .
Thanks for help....

0
 
David RobitailleAnalyst ProgrammerCommented:
I`m gald i could help!
0
 
David RobitailleAnalyst ProgrammerCommented:
thanks!
0
 
Rajar AhmedConsultantAuthor Commented:
ur always welcome .
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.