Click here to Skip to main content
15,908,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a gridview control which has some child controls inside that are TextBox, Dropdownlist. I am validaing this child controls using asp.net validation controls,
while performing validation if there is any error occured error message(Text="*") is displaying downside to TextBox and Dropdownlist.

but i want to display error message(Text="*") right side to child controls, is it possible?

here is my code follows:
XML
<FooterTemplate>
                           <asp:DropDownList ID="ddlVendorname" runat="server" AppendDataBoundItems="true" DataSource='<%# GetVendor() %>'
                               DataTextField="VendorName" DataValueField="CusVenID">
                               <asp:ListItem Value="-1">-Select-</asp:ListItem>
                           </asp:DropDownList>
                           <asp:RequiredFieldValidator ID="reqfvVendorName" runat="server" ControlToValidate="ddlVendorname"
                               InitialValue="-1" ValidationGroup="FtrowValidation" ErrorMessage="select Vendor"
                               Display="Dynamic" Text="*"></asp:RequiredFieldValidator>
                       </FooterTemplate>


XML
<FooterTemplate>
                            <asp:TextBox ID="txtZipcode" runat="server" Width="70" MaxLength="6"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="reqfvZipcode" runat="server" ControlToValidate="txtZipcode"
                                ErrorMessage="Enter Zipcode" ValidationGroup="FtrowValidation" Display="Dynamic"
                                Text="*"></asp:RequiredFieldValidator>
                            <asp:CompareValidator ID="cvZipcode" runat="server" ControlToValidate="txtZipcode"
                                Operator="DataTypeCheck" Type="Integer" Display="Dynamic" ErrorMessage="Zipcode should be numeric only"
                                ValidationGroup="FtrowValidation" Text="*"></asp:CompareValidator>
                        </FooterTemplate>


please anybody help me.

Thanks
Uday
Posted

Hi,

Increase your griedview control width property.

to show controls side by side

ASP.NET
<footertemplate>
                          <table width="100%" align="center"><tr><td> <asp:DropDownList ID="ddlVendorname" runat="server" AppendDataBoundItems="true" DataSource='<%# GetVendor() %>'
                               DataTextField="VendorName" DataValueField="CusVenID">
                               <asp:ListItem Value="-1">-Select-
                           </td><td>
                           <asp:RequiredFieldValidator ID="reqfvVendorName" runat="server" ControlToValidate="ddlVendorname"
                               InitialValue="-1" ValidationGroup="FtrowValidation" ErrorMessage="select Vendor"
                               Display="Dynamic" Text="*">
</td></tr></table>
                       </footertemplate>


All the Best
 
Share this answer
 
v2
You can place the control in a column and validator in another column in a table
ASP.NET
<footertemplate>
<table><tr><td>
                           <asp:dropdownlist id="ddlVendorname" runat="server" appenddatabounditems="true" datasource="<%# GetVendor() %>" xmlns:asp="#unknown">
                               DataTextField="VendorName" DataValueField="CusVenID">
                               <asp:listitem value="-1">-Select-</asp:listitem>
                           </asp:dropdownlist></td><td>
                           <asp:requiredfieldvalidator id="reqfvVendorName" runat="server" controltovalidate="ddlVendorname" xmlns:asp="#unknown">
                               InitialValue="-1" ValidationGroup="FtrowValidation" ErrorMessage="select Vendor"
                               Display="Dynamic" Text="*"></asp:requiredfieldvalidator></td>
</tr></table>
                       </footertemplate>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



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