Forms Data Controls :: How To Validate The Value In EVAL("field")
May 20, 2010IF statement which I use to validate the value in EVAL("field").
Here is my code in .ASPX
[code]....
IF statement which I use to validate the value in EVAL("field").
Here is my code in .ASPX
[code]....
I have the code below that works fine, but I need to have more than one field using the same command.
[Code]....
I need to validate a field when changing pages in a GridView:
<asp:GridView ID="GridView1" AllowPaging="true" PageSize="7" PagerSettings-Mode="NextPrevious"
PagerStyle-ForeColor="#1A7A5E" PagerSettings-NextPageText="Continue" OnPageIndexChanged=""
runat="server" DataSourceID="mainDS"
DataKeyNames="id" AutoGenerateColumns="False" RowStyle-BackColor="LightGray"
[Code]....
The following seems reasonable, but it returns an error:
<asp:Repeater ID="RepeaterF" runat="server" DataSourceID="DSF" >
<ItemTemplate>
<%
If Eval("Item_Batch") = 0 Then
%><tr><td></td><td colspan="2"></td><td></td></tr><%
Else %>........
Error: "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."
I am finding it difficult to accept that the whole Repeater approach has any benefits over just creating a loop in code, iterating through a recordset, and building a html table into a variable, then dumping it to the page. This repeater is spawning pages of code and objects, and surely this is all using up server resources.
I have a Gridview with a CommandButton for Update and a seperate Link Button in another column for Delete.
The problem is that when in Update mode if i click the Delete Link i get an exception error message.
I want to validate one field in the gridview i.e. user should select the same subject name from the checkboxlist item. Refer image [URL] ....
 Below is the html code and C# code for checkbox event
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="chkBxSelect" runat="server" AutoPostBack="true"
OnCheckedChanged="CheckBox1_CheckedChanged" />
</ItemTemplate></asp:TemplateField>
Â
[Code] ....
I have some hidden fields to which i want to assign values through properties in .aspx.cs file.How can i do so?
The following gives the error: Compiler Error Message: CS0103: The name 'Business' does not exist in the current context
[Code]....
Is it possible to have "Required Field Validator" controls to validate more than one field (example I have 12 textboxes that are required. I want to try an avoid having 12 RFV controls. If a validation does get triggered, is there a way to display a customized message ("textA is empty" or "textB is empty") etc.?
View 4 RepliesI got the difference between Bind and EVal from here. Bind will do both way reading and writing. And Eval do only reading. So any function only for writing?
View 1 Replieshere my code-
<asp:TemplateField HeaderText="HIGH RISK (10-12)" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblHighrisk" runat="server" Text='<%# Eval("URANGE").ToString().Split('-')[0] %>' />
</ItemTemplate>
</asp:TemplateField>
but that is giving compile time error 'Server tag is not well formed'
i have one hidden field and i want to bind it with two values of my data base separated by an coma. some thing like
->asp:HiddenField ID="hfRstidDate" runat="server" Value=<%# DataBinder.Eval(Container.DataItem, "tsk_ID"),DataBinder.Eval(Container.DataItem, "Date_Worked").ToString())%>
I want to validate the price field. This is my RegularExpressionValidator
<asp:RegularExpressionValidator
id="RegularExpressionValidator1"
ControlToValidate="txtPrixFormation"
ValidationExpression="^d+(?:.d{0,2})?$"
Display="Static"
EnableClientScript="false"
ErrorMessage="enter a dollar amount"
runat="server"/>
I want to validate the price field using RegularExpressionValidatorThis is the code I used. It worked except that when I modified the other fields, it gived me the message "Enter the dollar amount" at the price field. ( I don't want to touch the price field. I only want to modify the other fields )
<asp:TextBox
ID="txtPrixFormation"
runat="server"
[code]...
I want to use a RangeValidator Control which will validate my Password field where i want to check that if user enters less than 6 characters passwrod then it will prompt an error .
I want to give minimum & maximun password size ie minimum 6 characters. It could be alphanumeric & combination of special characters.
Maximum size should be 15 characterss.Same any combination o Alpha numeric or special charactors.
I have done it through Custom Validator .But how can i do this with Range Validator control.
I have a text field set up to accept a date: [Code]....
how to get the validator to make sure that the YEAR is acceptable. For instance, I can enter a year of "0000" and the validator will not catch it or display the error message. I can even enter a year of "9999" also. The only time the validator catches it is if I input something like "45/95/7589" for the date.
i want use this control for dropdownlist i wrote below code
<asp:DropDownList ID="DDL2" runat="server" CssClass="DPCDDL">
</asp:DropDownList>
<asp:RequiredFieldValidator Display = "Dynamic" ID="RequiredFieldValidator4" runat="server"
ErrorMessage="please select your classification." ControlToValidate="DDL1" CssClass="valid1"></asp:RequiredFieldValidator>
but it didn't work how i can define that users should select one item from DDL?
I have a datalist and would like to add an if statement within the Text part of my label.
Tried the following but it doesn't work
Note: if I do a normal eval Text='<%# Eval("UI_successful_trans")%>' the value returned from the database will be 1 or 0. Depending of which value is returned, I would like to have the text "Win" or "Lose" returned. ( I know that this could easily be done in code behind but I would like to know if it is
possible to to do that inline ?
[Code]....
[Code]....
i think its a simple problem but i am strugling with it i have list view, and in item template i am bounding a label with 2 fields that is first name and last name
i am tring this code
Text='<%# Eval("firstname") + Eval("lastname") %>'
/>
but it gives error taht Operator '+' cannot be applied to operands of type 'object' and 'object' for single value it works that is
Text='<%# Eval("firstname") %>'
/>
and even for constant concatenate it works that is
Text='<%# "India" + Eval("firstname") %>'
/> .... is working fine
I tried different arrangement but its not working that is
Text='<%# Eval("firstname","Lastname") %>'
/>
Text='<%# Eval("firstname" + "Lastname") %>'
/>
My web application works if I don't compile it, when I compile, it gives me this nasty error and I am clueless to what I did wrong?
Here is the error: No where in my line 113 has any Eval nor my entire page has any Eval, I used Bind so what is going on? the strange thing is if I leave the page as is with out Publish web site option the same page works perfectly fine.
BC30451: Name 'Eval' is not declared
Line 111: <asp:TemplateField HeaderText="Property Name" SortExpression="PropertyName">
Line 112: <ItemTemplate>
Line 113: <asp:Label ID="PropertyNameLabel" runat="server" Text='<%# Bind("PropertyName") %>'></asp:Label>
Source File: c:inetpubwwwrootJPM2010UserPropertySearch.aspx Line: 113
I have a repeater that has been given a datasource from my database containing pictures. The problem is that when i create and log a user into my site i send him to a folder that has no access from others than the ones with a roles called User. When he creates his profile, he uploads a picture which is saved in the same folder "User/picture/picturename" and in the database "picture/picturename".
Now i need to pull this picture to the Default page page where users are not logged in. If i add an Image Control to the frontpage with ImageUrl='<%#Eval ("PictureThumbURL") %>' it tries to pull out the picture from the folder User which is obvious that it can't since it lacks the User/ in front.
Is it possible to get this picture by manually adding User/ to the ImageUrl='<%#Eval ("PictureThumbURL") %>' and if so, how?
<asp:Label ID="Label13" Runat="Server" Text='<%# (decimal)Eval("CelaDnevnica") > 0 && (int)Eval("CelaDnevnicaStevilo") > 0 ?
Å t. ((double.Parse(Eval("CelaDnevnica").ToString())) / (double.Parse(Eval("CelaDnevnicaStevilo").ToString()))).ToString("0.00"): "" %>' ></asp:Label>
How to include text "Å t." according to a conditional sentence?If a conditional sentence is completed, the printed text "Å t." As well as CelaDnevnica / CelaDnevnicaStevilo
how to use regular expression in vbscript to validate username field. ie it should have minimum of 4 characters and at the same time it should contain minimum of 3 ALPHABETS. ie
1234 - not allowed
abc1 -allowed
My code
dim regObj,retVal
set regObj = new RegExp
regObj.Pattern ="[A-Za-z0-9_s]{4,}"
regObj.IgnoreCase = true
regObj.Global=True
retVal = regObj.Test(sString)
How can I validate the page using this javascript on Asp Button Control.
function PrintPanel() {
var panel = document.getElementById("<%=pnlContents.ClientID %>");
var printWindow = window.open('', '', 'height=700,width=1000');
printWindow.document.write('<html><head><title>Trainee Appraisal Form</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
}
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Print Only"
OnClientClick = "return PrintPanel();" />
I want to bind two column on single level in GridView
I m using this code
<asp:Label ID="Label1" runat="server" Text='<%# Eval("lChannelName")+ " " +Eval("lTransformData") %>' >
</asp:Label>
But i want to bind First column at Left hand side and second column from right hand side
I ran into this kind of situation many times without a nice solution. Binding a data source to a gridview and one of the column require nested query. Is it possible to have a callback function other than Eval()?
something like CallbackFunc(Eval("SomeField"));