?
Solved

how to validation in editmode of datagrid

Posted on 2008-11-06
10
Medium Priority
?
267 Views
Last Modified: 2013-12-17
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

0
Comment
Question by:Rajar Ahmed
  • 6
  • 3
9 Comments
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22894882
just but vlaidators between the <EditItemTemplate> tacg for eatch column you whant to valiadate

 
 
0
 
LVL 18

Author Comment

by:Rajar Ahmed
ID: 22894937
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
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22895004
well, you have to trun the BoundColumn into Template to add validators.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 18

Accepted Solution

by:
David Robitaille earned 2000 total points
ID: 22895034
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22896033
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
 
LVL 18

Author Comment

by:Rajar Ahmed
ID: 22897482
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
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22897516
I`m gald i could help!
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22906483
thanks!
0
 
LVL 18

Author Comment

by:Rajar Ahmed
ID: 22910780
ur always welcome .
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question