Forms Data Controls :: Validating TextBox Data Against Multiple Types Of Data
Dec 22, 2010
I m Using a GridView: Columns: "Ser_type" tells what type of data is it i.e. VC for Varchar, NU for Numeric, DT for DateTime etc, for the time being i m using datavalidation controlls at design time. this is not a good approach. I just wan to do is that, DataValidationControlls should be created at RunTime and TextBox should validate data at runtime only. i.e. if Data required in the TextBox is of Type VC then it should validate only at runtime, if DT then validate DateTime only at Runtime similarly for all dataType:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" >
</asp:ScriptManager>
<div>
<div>
<asp:Panel ID="Panel1" runat="server" Height="150px" Style="left: 0px; position: relative;
top: 0px" Width="970px">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Home.jpg" Style="position: relative" /></asp:Panel>
</div>
<div>
<asp:Panel ID="Panel2" runat="server" BackColor="PaleTurquoise" Height="350px" Style="left: 0px;
position: relative; top: 0px" Width="970px">
<asp:Label ID="lbl_Home" runat="server" Font-Bold="True" Font-Size="XX-Large" ForeColor="#404040"
Style="position: relative" Text="Welcome to AutoSoft Dynamics" Width="700px"></asp:Label> <br />
<table style="left: 0px; position: relative; top: 0px">
<tr>
<td colspan="2" style="height: 21px">
<asp:Label ID="lbl_messege" runat="server" Style="position: relative" Font-Bold="True" Font-Size="16pt" ForeColor="#0000C0" Width="100%"></asp:Label></td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblExpMessage" runat="server" Style="position: relative" Width="100%" Font-Bold="False" Font-Size="12pt" ForeColor="Red"></asp:Label></td>
</tr>
<tr>
<td style="width: 464px">
<asp:Button ID="Button1" runat="server" Style="position: relative" Text="Button" />
<asp:Button ID="Button2" runat="server" PostBackUrl="~/EmpDetails.aspx" Style="position: relative"
Text="Go to Details Page" /></td>
<td style="width: 162px">
</td>
</tr>
</table>
<br />
</asp:Panel>
<asp:Panel ID="Panel3" runat="server" BackImageUrl="~/Images/Footer.bmp" Height="50px"
Style="left: 0px; position: relative; top: 0px" Width="970px">
</asp:Panel>
<br />
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
BackgroundCssClass="modalBackground"
PopupControlID="Panel_Popup"
CancelControlID="btnRemindLater"
TargetControlID="Button1" >
</cc1:ModalPopupExtender>
<asp:Panel ID="Panel_Popup" runat="server" Width="540px" HorizontalAlign="Center" >
<br />
<table width="100%" style="left: 0px; position: relative; top: 0px; background-color: inactivecaptiontext">
<tr>
<td colspan="4">
<asp:Label ID="lbl_Title" runat="server" BackColor="Desktop" Font-Bold="True" ForeColor="White"
Height="28px" Style="font-weight: bold; font-size: 15pt; vertical-align: middle;
position: relative; text-align: center" Width="100%"></asp:Label></td>
</tr>
<tr>
<td style="width: 11px">
</td>
<td style="width: 583px">
<asp:GridView ID="GridView_Popup" runat="Server" AutoGenerateColumns="False" BorderColor="Navy"
BorderStyle="Solid" BorderWidth="2px" CellPadding="3" DataKeyNames="ser_no" EmptyDataText="No recored found"
Font-Bold="False" ForeColor="Black" GridLines="Horizontal" HorizontalAlign="Left"
OnRowDataBound="GridView_Popup_RowDataBound" Style="position: relative">
<EmptyDataRowStyle BorderColor="Navy" BorderWidth="2px" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lbl_ser_no" runat="server" Font-Size="1pt"
Text='<%# Bind("ser_no") %>' ForeColor="ActiveCaptionText" >
</asp:Label>
</ItemTemplate>
<HeaderStyle BackColor="GradientInactiveCaption" />
<ItemStyle HorizontalAlign="Left" Width="5px" ForeColor="ActiveCaptionText" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<asp:Label ID="lbl_description" runat="server" Font-Size="Small" Text='<%# Bind("description") %>'
Width="110px">
</asp:Label>
</ItemTemplate>
<HeaderStyle BackColor="GradientInactiveCaption" Font-Bold="True" Font-Size="Small"
ForeColor="White" HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="110px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Declared Value">
<ItemTemplate>
<asp:TextBox ID="txt_DeclaredValue" runat="server" CausesValidation="True" Font-Size="Small"
Text='<%# Eval("declared_value") %>' ToolTip='<%# Eval("ser_help") %>' Width="205px" MaxLength="50"></asp:TextBox>
</ItemTemplate>
<HeaderStyle BackColor="GradientInactiveCaption" Font-Bold="True" Font-Size="Small"
ForeColor="White" HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="205px" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lbl_Mandatory" runat="server" Font-Size=".5pt" ForeColor="inactivecaptiontext"
Text='<%# Bind("mandatory") %>' Width="15px"></asp:Label>
</ItemTemplate>
<HeaderStyle BackColor="GradientInactiveCaption" Font-Size="Small" />
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="15px" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lbl_ser_type" runat="server" Font-Size=".5pt" ForeColor="inactivecaptiontext"
Text='<%# Bind("ser_type") %>' Width="15px"></asp:Label>
</ItemTemplate>
<HeaderStyle BackColor="GradientInactiveCaption" />
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="15px" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:RequiredFieldValidator ID="rfv_declaredVal" runat="server" ControlToValidate="txt_DeclaredValue"
ErrorMessage="*" >
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="rfv_num" runat="server"
ControlToValidate="txt_DeclaredValue" Display="Dynamic" Enabled="false" ErrorMessage="Only (0-9)"
ValidationExpression="^[0-9]*$" Font-Size="10pt" >
</asp:RegularExpressionValidator>
<asp:RegularExpressionValidator ID="rfv_NonNumeric" runat="server" ControlToValidate="txt_DeclaredValue"
Enabled="false" ErrorMessage="Only (a-z/A-Z)" ValidationExpression="^[a-zA-Z'.s]{1,40}$" Font-Size="10pt" >
</asp:RegularExpressionValidator >
<asp:CompareValidator ID="cv_txtDate" runat="server"
ControlToValidate="txt_DeclaredValue" ErrorMessage="dd/MM/yyyy only"
Operator="DataTypeCheck" Type="Date" Font-Size="10pt" >
</asp:CompareValidator>
<asp:RegularExpressionValidator ID="rev_Decimal" runat="server" ErrorMessage="Only Decimal"
ControlToValidate="txt_DeclaredValue" Style="position: relative" Font-Size="10pt"
ValidationExpression="(?!^0*$)(?!^0*.0*$)^d{1,18}(.d{1,2})?$" />
</ItemTemplate>
<HeaderStyle BackColor="GradientInactiveCaption" />
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
</asp:TemplateField>
</Columns>
<HeaderStyle BorderColor="Navy" BorderStyle="Solid" BorderWidth="1px" ForeColor="#0000C0"
Height="25px" HorizontalAlign="Left" VerticalAlign="Middle" />
</asp:GridView>
</td>
<td style="width: 10px">
</td>
</tr>
<tr>
<td style="width: 11px; height: 26px">
</td>
<td style="width: 583px; height: 26px">
<table style="left: 0px; width: 100%; position: relative; top: 0px">
<tr>
<td style="width: 63px; height: 26px">
<asp:Button ID="btnSubmit" runat="server" Style="left: 0px;
position: relative; top: 0px" Text="Submit" OnClick="btnSubmit_Click1" />
</td>
<td style="width: 100px; height: 26px">
<asp:Button ID="btnRemindLater" runat="server" OnClientClick="winclose()"
Style="left: 0px; position: relative" Text="Remind Me Later" UseSubmitBehavior="False"
Width="120px" />
</td>
<td style="vertical-align: middle; width: 304px; height: 26px; text-align: right">
<asp:Label ID="lbl_LastDatePopup" runat="server" Font-Bold="False" Font-Size="Small"
ForeColor="Red" Style="position: relative" Width="100%"></asp:Label></td>
</tr>
</table>
<asp:Label ID="Label1" runat="server" BackColor="InactiveCaptionText" Style="position: relative">
</asp:Label><asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="Please correct the mandatory fields labeled with * "
Height="1px" ShowMessageBox="True" ShowSummary="False" Style="position: relative" />
</td>
<td style="width: 10px; height: 26px">
</td>
</tr>
</table>
<br />
</asp:Panel>
</div>
</div>
</form>
View 4 Replies
Similar Messages:
Mar 22, 2010
i have textboxes(edititemtemplate and footertemplate) inside a gridview.
i want to prevent the user from entering hyphen(-) in the textboxes.
View 2 Replies
Mar 24, 2010
I am using a bound gridview in ASP.NET 2.0. The gridview has the ability to edit/update and insert rows. One of the columns holds a number which represents a percentage. What I cannot figure out is how to ensure that all the rows in the gridview total 100% before being able to send the updates or newly inserted data to the database.
For example say there are 5 rows in the gridview, each row has 20% stored in the column so it adds up to 100% which is fine, the data is updated/inserted in the database. But say each row only had 15% totalling 75%, the user should not be able to send the updated/inserted data to the database until either they add a new row with a percentage of 25 or they edit the other rows for a cumulative total of 100%
I am not familiar with javascript or AJAX
View 6 Replies
Sep 20, 2015
Using code found here : [URL] .... I was wondering if the text could be formatted as in maintaining line feeds. I'm reading from an SQL 2008 database which has a text field. When I call it up the text format is gone. as an example I get :
what colour is the sun A:Green B:Red c:Yellow
instead of :
what colour is the sunA:Green B:Red c:Yellow
View 1 Replies
Jul 2, 2010
multiple email address are enetered in the textbox at present i have used SPLIT function to split the emails based on a delimiter on server side wht i need is , suppose i have 10 email addrees in the textbox and suppose 3rd one is not valid i dont want the processing to be stopped at 3rd , if 3rd is invalid it shld be skipped and the 4th one shld be processed.
View 10 Replies
Aug 31, 2010
I need help writing a class that will contain three values per item. I'll be passing parameters to a report: Parameter Name, Data type (int, string, date, etc), and Value. When I pass those values to the report using the class they should be in original form (i.e. an integer should be a numeric, a string should be a string, etc.).
I can do it converting the data's value to strings on one end, and reconverting to the original data type on the other, which seems like a lot of runaround. Is there a simple way? Also, if I'm able to store & retrieve the data in it's native format I don't need the "Data type" stored.
View 2 Replies
Jul 22, 2013
I created 3 product table . A,B and c.
I show product of table in different gridview.
Now I am using one search box. but how to search product name with image in one query all of three table....
Simple how to search product from multiple table and show result...
View 1 Replies
Sep 9, 2010
I have Gridview with Dropdownlist which contains data as {select,1,2,3} .Gridview contains multiple rows of data.Submit button is also on form but outside gridview. If any of the rows of gridview dropdownlist contain value as "Select" and click Submit button ,give message as "Please select value". I want to do this stuff using javascript.
View 8 Replies
May 27, 2010
I have a textbox "SerialTextBox" that is bound to a parameter "Serial".
This is bound as follows:
<asp:TextBox
ID="SerialTextBox"
runat="server"
Text='<%# Bind("Serial") %>'
/>
I have another parameter called "CountryCode" which is the result of a SQL select.
What I need to do is define the value of a third parameter called "CountrySerial".
This parameter is a concatenation of CountryCode (eg 'UK') + Serial (eg 'sn123') resulting in 'UKsn123'.
I was hoping to do this in the above binding...
Something LIKE...
<asp:TextBox
ID="SerialTextBox"
runat="server"
Text='<%# Bind("Serial") , [CountryCode +"CounrtySerial"] %>'
/
>
I know this newbie sytax is way off.
There are two parts to my question...
(1) how do I bind SerialTextBox to TWO items?
(2) how do I concatenate "CountryCode" to "CountrySerial" during the binding?
View 6 Replies
May 27, 2010
I have been stuck on an issue that is driving me mad and I bet its simple. I have a Textbox with a gridview and a LINQ statement in code behind that populates the data source of the gridview at page load.
The Textbox is used as a filter for the where clause in the Linq statement. All works as expected however I want to be able to use more than one word as a filter. This is the problem. I take the textbox string and convert to an array
Dim aryTextFile() As String = SearchString.Split(",")
But I need to figure how to pass the values of the array as parameters for the Linq Statement. I need to return all rows that have either a match for LocationName AND/OR Address AND/OR City. I thought of something like this but it fails.
Dim db As New DCLocationsDataContext
Dim q = From t In db.Locations _
Where t.City AndAlso t.LocationName AndAlso t.Address Like aryTextFile _
Select t
GridView1.DataSource = q
GridView1.DataBind()
View 6 Replies
Feb 1, 2011
I have gridview with 3 columns and one textbox in each column. My requirement is when i paste 3 cells of copied data from excel to textbox in first column of gridview automatically 2nd cell data has to be pasted in textbox of 2nd column and 3rd cell data to textbox of 3rd column of gridview. How can it be done and can anyone provide the best code.
View 3 Replies
Jun 14, 2010
How can i read multiple textbox values inside gridview? as well as getting the specified row id?
View 3 Replies
Aug 24, 2010
I have a textbox and a gridview which is bound to a table what I want to achieve is a solution where lets say there are two records - e.g. "1. Book and 2. Red", i want a user to type in those words and the gridview shows the results as followed;
1. Book
2. Red
I have set up the sql data source and everything and my like operator is this.
LIKE '%' + @record + '%'
how can I solve this problem?
View 3 Replies
May 19, 2010
I have two AccessDataSources each returning one row.
I want to use the data in each row to populate content on my page, so I figured I would use a [Code].... or [Code].....
However, I would not necessarily want the labels bound to a particular DataSource placed together.
For example, I might want labels from the following columns in order [Code]....
:
[Code]....
Note: No language preference (C#/VB).
View 2 Replies
Nov 19, 2010
I have a page in which i need to show data in the form of a grid. Each row in the grid is made up of 2 sub-rows, the first sub-row consists of a dropdown, a textbox & a textarea. Whatever is entered in these controls should be displayed in the second sub-row in the form of labels at runtime (i.e. using javascripts)
There can be multiple rows like this. The grid would have a max of 30 row, not more than that. create this which one would be better, in terms of performance & complexity, a GridView or a DataRepeater?
View 2 Replies
Feb 25, 2011
i have 103 column in database 1 column is id, 1 is user ,1 datetime, 100 button on webpage 1 textbox to input value , button1 clicked then value in textbox will insert into database with user:=user.identity.nam datetime=datetime.now colum4 will get value from textbox......button2 for colum2 and buton100 for column100, if i use dataset i need 100 datataset, some other way to solve it ??
View 2 Replies
Oct 26, 2010
I'm inserting data into a SQL database through a detailsview. When a user inserts an incorrect data type or leaves a required field blank it shoots off to a big error screen. Is there a control that I can use that will allow it to give an error (with a little star or something) that says which field is incorrect without the big error screen?
View 3 Replies
Jan 27, 2011
I added requiredvalidator to validate the input field in hte detailviews control. the only probably problem is error message shows up when form popup. I only want to show the error message after I click on the submit button. here's my code.
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/main.Master"
CodeBehind="WebForm4.aspx.vb" Inherits="hospital.WebForm4" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:GridView ID="gvList" runat="server" DataKeyNames="taxID" DataSourceID="odsList"
EnableModelValidation="True">
<Columns>
<asp:CommandField ShowSelectButton="True" />
</Columns>
</asp:GridView>
<asp:DetailsView ID="dvDetail" runat="server" DataSourceID="odsDetail" EnableModelValidation="True"
Height="50px" Width="125px" DefaultMode="Edit">
</asp:DetailsView>
<asp:ObjectDataSource ID="odsList" runat="server" SelectMethod="GetHospitals" TypeName="hospital.Hospital">
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="odsDetail" runat="server" SelectMethod="GetHospitalsByTaxID"
TypeName="hospital.Hospital" UpdateMethod="Update">
<SelectParameters>
<asp:ControlParameter ControlID="gvList" Name="taxID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:ControlParameter ControlID="dvDetail" Name="nTaxID" PropertyName="SelectedValue"
Type="Int32" />
<asp:ControlParameter ControlID="dvDetail" Name="sHospitalName" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="dvDetail" Name="sAddress1" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="dvDetail" Name="sAddress2" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="dvDetail" Name="sCity" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="dvDetail" Name="sState" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="dvDetail" Name="sZip" PropertyName="SelectedValue"
Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
<asp:LinkButton ID="lbnSave" runat="server">Save</asp:LinkButton>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:ModalPopupExtender ID="upAdd_ModalPopupExtender" runat="server" TargetControlID="btnAdd"
PopupControlID="pnlAdd" BackgroundCssClass="modalBackground" OkControlID="btnOk"
CancelControlID="btnClose">
</asp:ModalPopupExtender>
<asp:Button ID="btnAdd" runat="server" Text="Add" />
<asp:Panel ID="pnlAdd" runat="server" CssClass="modalPopup">
<asp:UpdatePanel ID="upAdd" runat="server" UpdateMode="Conditional">
<ContentTemplate>
sdfsdfsdfsdfsdf
<asp:FormView ID="FormView1" runat="server" DataSourceID="odSrcHospital" DefaultMode="Insert">
<InsertItemTemplate>
<table>
<tr>
<td>
taxid
</td>
<td>
<asp:TextBox ID="tbxTaxID" runat="server" Text='<%# Bind("nTaxID") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvTaxID" runat="server" ControlToValidate="tbxTaxID"
ErrorMessage="Required" Display="Static" SetFocusOnError="true" />
</td>
</tr>
<tr>
<td>
h name
</td>
<td>
<asp:TextBox ID="tbxName" runat="server" Text='<%# Bind("sHospitalName") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvHospitalName" runat="server" ControlToValidate="tbxName"
ErrorMessage="Required" Display="Static" SetFocusOnError="true" />
</td>
</tr>
<tr>
<td>
add1
</td>
<td>
<asp:TextBox ID="tbxAdd" runat="server" Text='<%# Bind("sAddress1") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvAddress" runat="server" ControlToValidate="tbxAdd"
ErrorMessage="Required" Display="Static" SetFocusOnError="true" />
</td>
</tr>
<tr>
<td>
add2
</td>
<td>
<asp:TextBox ID="tbxAdd2" runat="server" Text='<%# Bind("sAddress2") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvAddress2" runat="server" ControlToValidate="tbxAdd2"
ErrorMessage="Required" Display="Static" SetFocusOnError="true" />
</td>
</tr>
<tr>
<td>
city
</td>
<td>
<asp:TextBox ID="tbxCity" runat="server" Text='<%# Bind("sCity") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvCity" runat="server" ControlToValidate="tbxCity"
ErrorMessage="Required" Display="Static" SetFocusOnError="true" />
</td>
</tr>
<tr>
<td>
state
</td>
<td>
<asp:TextBox ID="tbxState" runat="server" Text='<%# Bind("sState") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvState" runat="server" ControlToValidate="tbxState"
ErrorMessage="Required" Display="Static" SetFocusOnError="true" />
</td>
</tr>
<tr>
<td>
zip
</td>
<td>
<asp:TextBox ID="tbxZip" runat="server" Text='<%# Bind("sZip") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvZip" runat="server" ControlToValidate="tbxZip"
ErrorMessage="Required" Display="Static" SetFocusOnError="true" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="submit" Text="submit" runat="server" CommandName="Insert" />
</td>
</tr>
</table>
</InsertItemTemplate>
</asp:FormView>
<br />
<br />
<asp:Button ID="btnOk" runat="server" Text="Ok" />
<asp:Button ID="btnClose" runat="server" Text="Close Me" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<asp:ObjectDataSource ID="odSrcHospital" TypeName="hospital.Hospital" SelectMethod="GetHospitals"
runat="server" DeleteMethod="Delete" InsertMethod="Update" UpdateMethod="Update">
<DeleteParameters>
<asp:ControlParameter Direction="Input" DefaultValue="0" ControlID="grdHospital"
Name="taxID" />
</DeleteParameters>
<InsertParameters>
<asp:FormParameter FormField="tbxTaxID" Name="nTaxID" Direction="Input" />
<asp:FormParameter FormField="tbxName" Name="sHospitalName" Direction="Input" Type="String" />
<asp:FormParameter FormField="tbxAdd" Name="sAddress1" Direction="Input" Type="String" />
<asp:FormParameter FormField="tbxAdd2" Name="sAddress2" Direction="Input" Type="String" />
<asp:FormParameter FormField="tbxCity" Name="sCity" Direction="Input" Type="String" />
<asp:FormParameter FormField="tbxState" Name="sState" Direction="Input" Type="String" />
<asp:FormParameter FormField="tbxZip" Name="sZip" Direction="Input" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="nTaxID" Type="Int32" />
<asp:Parameter Name="sHospitalName" Type="String" />
<asp:Parameter Name="sAddress1" Type="String" />
<asp:Parameter Name="sAddress2" Type="String" />
<asp:Parameter Name="sCity" Type="String" />
<asp:Parameter Name="sState" Type="String" />
<asp:Parameter Name="sZip" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
</asp:Content>
View 5 Replies
Apr 11, 2010
I have the following piece of code which I was hoping would result in an error message being displayed if an incorrect date format was input rather than an website error page saying "The string was not recognized as a valid DateTime."
<asp:TemplateField HeaderText="DateCompleted" SortExpression="DateCompleted"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("DateCompleted") %>'> </asp:TextBox> <asp:CompareValidator ID="CompareValidator" ValidationGroup="GridView1" ControlToValidate="TextBox2" errormessage="Invalid Date" Display="Dynamic" Operator="DataTypeCheck" Type="Date" runat="Server" /> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("DateCompleted") %>'></asp:Label> </ItemTemplate> </asp:TemplateField>
View 2 Replies
Feb 8, 2010
I have two dropdowns in the footertemplate of my gridview inside a usercontrol.
I also have a button "btnADD" inside the footer template. I am using the footertemplate to add a new row to the grid.
What do I do to validate on Button_click event for 'btnAdd' if a value is selected in the dropdown other than "select.." which I dynamically add in rowdatabound event?
I have this javascript function that I wanted to implement, but it gets called in the Page_load event rather than the button click event and gives an error.
The javascript function that I need to call is this: ( I created a method to return a string to use it in regards to RegisterClientScriptBlock, but do not know exactly how to use it)
rotected string BuildValidation()
{
StringBuilder sb = new StringBuilder();
sb.Append("<script type='text/javascript'>");
sb.Append("function ValidateWComp() {");
[Code]....
View 1 Replies
Sep 9, 2010
Object cannot be cast from DBNull to other types. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Object cannot be cast from DBNull to other types. Source Error:
[Code]....
Line 292:
Line 293: If DataBinder.Eval(e.Row.DataItem, "Casette") IsNot Nothing Then
Line 294: stcassette += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Casette"))
Line 295: End If
Line 296:
View 6 Replies
Mar 10, 2010
There are two dropdowns for date (Fromdate and Todate) in my webpage and by default when the page loads for the first time the dropdowns loads with the last date (currentdate), if I select some previous date in Fromdate dropdown and reload the page then it displays runtime i.e.
Object cannot be cast from DBNull to other types.
Following code is written under GridView RowDataBound Event.
[Code]....
The error found at following line:
less7daysTotal += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "less7days"))
If I comment this line then the error moves to next line till following line.
grt28daysTotal += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "grt28days"))
I fruther want to inform that some columns in the grid are showing 0 if there is no record but I replaced 0 to - then some 0s replaced and some not. What is the reason?
View 30 Replies
Jul 8, 2010
I have a Gridview and a UserControl on the same page. How do I prevent update button on the gridview from validating Usercontrol.
View 4 Replies
Jun 16, 2015
I am developing a message pool means like a Facebook when we click on above message icon all message show in list .then click on the sender name all message show that person. For
That kind of message poll am developed two pages one page is sender and the other one is receiver .when I send message from sender page it will be saved into data base and show into other pages text box.
Now problem is that the receiver pages cannot show all messages .it will show one first message which are saved into database.
I want it will show all messages which are sending from sender page. below my all code.
WebForm1.aspx.css
using System;
using System.Collections.Generic;
using System.Linq;
[Code].....
View 1 Replies
Nov 21, 2010
I have a listview in which I have a dropdownlist that will be repeated about 8 times. In the itemdatabound event of this listview, I fill the dropdownlist of that particular row with data. I obtain this data by using a linq query. It gets me an anonymous type in return:
[Code]....
The problem with this code is that I fire a query to the database everytime the itemdataboundevent is called. What I want to do is to fire the query only once, and have it available at page scope so I can reference it in the itemdatabound event. How can I get it like that?
View 1 Replies