943,670 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 19741
  • ASP.NET RSS
Jan 8th, 2009
0

validation of textbox in gridview

Expand Post »
hi ...
thanks a lot..i got how to edi,update,n delete..now i want to validate the textbox wen i press update...like i want to ckeck for null vlues entry...only numbers.......i am searching for javascript but no proper result...

any links ..pls post....
Similar Threads
Reputation Points: 7
Solved Threads: 0
Newbie Poster
divyasrinivasan is offline Offline
21 posts
since Dec 2008
Jan 8th, 2009
0

Re: validation of textbox in gridview

Hi divyasrinivasan,

This is for validating textbox for numeric only :

ASP.NET Syntax (Toggle Plain Text)
  1. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="OperationSheetMultipleArticle.aspx.vb" Inherits="OperationSheetMultipleArticle" EnableSessionState="true" %>
  2. <%@ OutputCache Location="Client" duration="5" varybyparam="none" %>
  3. <html xmlns="http://www.w3.org/1999/xhtml" >
  4. <script type="text/javascript" language=javascript>
  5. function keyDownNumber()
  6. {
  7. var key;
  8. if(navigator.appName == 'Microsoft Internet Explorer')
  9. key = event.keyCode;
  10. else
  11. key = event.which
  12.  
  13. if ( !(key >= 48 && key <= 57) && key != 8 && key != 46 && key != 36 && key != 37)
  14. {
  15. event.returnValue = false;
  16. }
  17. }
  18. </script>
  19. <head runat="server">
  20. <title>Operation Sheet</title>
  21. </head>
  22. <body leftmargin=5 topmargin=3>
  23. <form id="form1" runat="server">
  24. <asp:GridView ID="GVDetail" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="LightGray"
  25. BorderColor="White" BorderStyle="Ridge" BorderWidth="1px" CaptionAlign="Top" CellPadding="0" Font-Size="12px" Font-Strikeout="False" Font-Underline="False" Height="1px" HorizontalAlign="Left" Style="left: 4px; top: 127px" UpdateAfterCallBack="True" Width="100%" EmptyDataText="NO RECORD FOUND" PageSize="12">
  26. <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
  27. <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
  28. <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" Font-Italic="False" Font-Underline="False"
  29. ForeColor="#E7E7FF" />
  30. <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
  31. <Columns>
  32. <asp:templatefield headertext="Del." >
  33. <itemstyle borderstyle="None" font-size="8pt" width="10px" horizontalalign="Center" />
  34. <headerstyle font-bold="False" width="10px" font-size="8pt"/>
  35. <itemtemplate>
  36. <asp:CheckBox id="ChkDelete" runat="server" width="20px" ></asp:CheckBox>
  37. </itemtemplate>
  38. </asp:templatefield>
  39. <asp:templatefield headertext="Article No.">
  40. <itemstyle borderstyle="None" font-size="8pt" width="20px" />
  41. <headerstyle font-bold="False" width="65px" font-size="8pt"/>
  42. <itemtemplate>
  43. <asp:TextBox id="TxtArticleNo" readonly=true text='<% # eval("ArticleNo") %>' runat="server" width="65px" borderstyle="None" font-size="8pt" BackColor="LightCyan" autocallback=true></asp:TextBox>
  44. </itemtemplate>
  45. </asp:templatefield>
  46. <asp:templatefield headertext="Amount">
  47. <itemstyle borderstyle="None" font-size="8pt" width="20px" />
  48. <headerstyle font-bold="False" width="65px" font-size="8pt"/>
  49. <itemtemplate>
  50. <asp:TextBox id="Amount" text='<% # eval("Amount") %>' runat="server" width="65px" borderstyle="None" font-size="8pt" onkeypress="keyDownNumber()" BackColor="Beige"></asp:TextBox>
  51. </itemtemplate>
  52. </asp:templatefield>
  53. </Columns>
  54. <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
  55. <AlternatingRowStyle BackColor="LightGray" />
  56. </asp:GridView>
  57. </form>
  58. </body>
  59. </html>

Thanks,
Reputation Points: 11
Solved Threads: 17
Junior Poster
Kusno is offline Offline
191 posts
since Aug 2007
Jan 10th, 2009
-1

Re: validation of textbox in gridview

can u pls explain wat u hVE DONE..PLA
Reputation Points: 7
Solved Threads: 0
Newbie Poster
divyasrinivasan is offline Offline
21 posts
since Dec 2008
Jan 24th, 2010
0

Adding validation to textbox in gridview using VB.NET

Hi there... still new so please forgive me if I make a mistake... to add validation to a textbox that is inside a gridview...
1. Convert the field into a text field...
2. then add validation into the <EditItemTemplate></EditItemTemplate> and the <InsertItemTemplate></InsertItemTemplate>

as below... :
ASP.NET Syntax (Toggle Plain Text)
  1. <asp:TemplateField HeaderText="Client Number" SortExpression="ClientNumber">
  2. <EditItemTemplate>
  3. <asp:TextBox ID="txtClientNumber" runat="server" Text='<%# Bind("ClientNumber") %>'></asp:TextBox>
  4. </EditItemTemplate>
  5. <InsertItemTemplate>
  6. <asp:TextBox ID="txtClientNumber" runat="server" Text='<%# Bind("ClientNumber") %>'></asp:TextBox>
  7. <asp:RequiredFieldValidator ID="val1" runat="server" ControlToValidate="txtClientNumber" ErrorMessage="Client Number Required" Display="Dynamic"></asp:RequiredFieldValidator>
  8. </InsertItemTemplate>
  9. <ItemTemplate>
  10. <asp:Label ID="Label1" runat="server" Text='<%# Bind("ClientNumber") %>'></asp:Label>
  11. </ItemTemplate>
  12. <ControlStyle CssClass="editControlTextFields" Width="96%" />
  13. <HeaderStyle Width="110px" />
  14. </asp:TemplateField>
Last edited by Ezzaral; Jun 16th, 2010 at 2:45 pm. Reason: Added code tags. Please use them to format any code that you post.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
NeonBlue007 is offline Offline
4 posts
since Jan 2010
Jun 16th, 2010
0

javascript for the below validation

how to check the text boxes while editing is the textbox is null or not
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jayanthan.jvp is offline Offline
1 posts
since Jun 2010
Jun 16th, 2010
0
Re: validation of textbox in gridview
you can also use in built validation controls provided by .net framework instead of java script.
Reputation Points: 17
Solved Threads: 56
Posting Whiz in Training
rohand is offline Offline
293 posts
since Mar 2010
Jul 15th, 2010
0
Re: validation of textbox in gridview
USE thid.id as argument in Validate function.
like I have my javascript function validateData(source) and I called it as follows on update link OnClientClick="return validateData(this.id);"
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cloudlight is offline Offline
2 posts
since Jul 2010
Jul 19th, 2010
0
Re: validation of textbox in gridview
HERE IS THE LINK TO DEMO THAT I HAVE CREATED
This is very simple demo.

http://www.aboriginalsystems.com/bha...AccessDemo.zip
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cloudlight is offline Offline
2 posts
since Jul 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: delegate problem in Login1_Loggedin
Next Thread in ASP.NET Forum Timeline: ASP.Net master page multi language





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC