|
I have added Imports System.Linq to my declaration however
Getting errors below:
'AsEnumerable' is not a member of 'System.Data.DataTable'.
item' is not declared. It may be inaccessible due to its protection level
|
|
|
|
|
Make sure you have a reference to the System.Data.DataSetExtensions assembly, and an Imports System.Data declaration at the top of your file.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have added all references however still the following lines won't compile.
Option Strict On requires all variable declarations to have an 'As' clause.
Dim data = myDataTable.AsEnumerable().GroupBy(Function(r) New With {Key .ID = r.Field(Of Integer)("ID"), Key .Code = r.Field(Of Integer)("Code")},
and
'item' is not declared. It may be inaccessible due to its protection level.
For Each item In data
|
|
|
|
|
You're using an anonymous type, so you can't give the variables an explicit type.
Try setting Option Infer On , which should allow the compiler to infer the type for you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
it worked. Now I am facing different issue when adding a new row into new table with non key columns
result.Rows.Add .... item.EENAML.. etc.
Could you tell me what am I doing wrong?
Here my full code
Dim data = myDataTable.AsEnumerable().GroupBy(Function(r) New With {Key .EEGRP = r.Field(Of String)("EEGRP"), Key .EESSN = r.Field(Of String)("EID")},
Function(key, rows) New With
{
Key .EEGRP = key.EEGRP,
Key .ESSN = key.EID,
.Dates = rows.Select(Function(r) r.Field(Of DateTime?)("DEIBCY") & ("DIIBYR") & ("D.DIIBMT") & ("DEIBDY")) _
.OrderByDescending(Function(d) d).Take(3).ToList()
})
Dim result As New DataTable
result = myDataTable.Clone()
For Each item In data
result.Rows.Add(item.EEGRP,item.EID, item.EENAML,item.EENAMF,item.EENAMM,item.EEADD1,item.EEADD2,,,, _
|
|
|
|
|
What's the error message?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
'FIELD' is not a member of '<anonymous type="">'; it does not exist in the current context.
|
|
|
|
|
Make sure you have a reference to the System.Data.DataSetExtensions assembly, and an Imports System.Data declaration at the top of your file.
The Field(Of T) method is an extension method defined in that namespace and assembly:
DataRowExtensions.Field<T> Method (DataRow, String)[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
When I add
Imports System.Data.DataSetExtensions
Module ModuleMain...
it saying it can't be found.
I do have reference added to the project.
|
|
|
|
|
The assembly is System.Data.DataSetExtensions ; the namespace is System.Data .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
When I change my project properties to .net 3.5 I was able to add
Imports System.Data.DataSetExtensions
however even with that I still having issues with no key fields for selecting
is not a member of '<anonymous type="">'; it does not exist in the current context
For Each item In data
result.Rows.Add(item.EEGRP,item.ESSN, item.EENAML,item.EENAMF,item.EENAMM,item.EEADD1,item.EEADD2,...._
|
|
|
|
|
please can tell anyone about asp.net architecture in simple way
|
|
|
|
|
|
Hello,
I want to create the unit test for the windows 10 universal app but I don't want to use the Microsoft Unit test app.
Could anyone recommend me the third party tool to test the unit test cases fro the windows 10 universal app.
Thanks in advance.
|
|
|
|
|
Hello
The above is the error message I am getting followed by a long Stack Trace.
I have a small form here http://www.dimadayoub.net/contact.aspx[^] and, to test it, I leave the email field blank on purpose (when I do the same for the other two fields, Name and Message, I get an on screen warning to complete the fields - which is what should happen).
When I do the same with the email field, I get the above server error. The relevant code I have is this:
<p><asp:Label ID="Email" runat="server" Text="Email"></asp:Label>
<asp:TextBox ID="your_email" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ErrorMessage="*" ControlToValidate="your_email"
ValidationGroup="vgSubmit" ForeColor="#FF6666"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" Display="Dynamic" ErrorMessage="Please complete the Email field"
ValidationGroup="vgSubmit" ControlToValidate="your_email"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></p>
What should I be correcting, please?
|
|
|
|
|
Remove the ValidationGroup="vgSubmit" attribute from both validators. Neither of your other validators have a validation group set, and neither does your submit button.
Specifying Validation Groups | MSDN[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Many thanks, Richard, for your reply.
I have done as you suggested and made a couple of other alterations.
The code now looks like this:
<p><asp:Label ID="Email" runat="server" Text="Email"></asp:Label>
<asp:TextBox ID="your_email" runat="server" ></asp:TextBox>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="SingleParagraph" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ErrorMessage="*" ControlToValidate="your_email" Display="None"
ForeColor="#FF6666"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" Display="None" ErrorMessage="Please complete the Email field"
ControlToValidate="your_email"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></p>
The result is that when I complete the 3 fields correctly, the form is sent.
When I complete the Name and Message fields, and Email field (without the @), I get an on screen error: 'Please complete the Email field' (for some reason it is in a white font and not the red of ="#FF6666"). I will amend that so it reads 'Please enter a valid email address'.
When I leave the email field blank entirely (the form does not get sent, which is fine), but I can see a little asterisk. I presume that asterisk is this:
ErrorMessage="*"
Can I not replace that asterisk with the on screen message: 'Please complete the Email field'?
Thanks again.
|
|
|
|
|
The ErrorMessage is the message that gets displayed in the ValidationSummary . The Text is the message that gets displayed in-line. If you set the ErrorMessage without setting the Text , the same message is used in both places.
You've used Display="None" , so the validators aren't showing up in-line. Instead, the ValidationSummary is showing all of the error messages next to the email field. You haven't applied any styles to the ValidationSummary , which is why the messages are white.
I'd be inclined to put a single ValidationSummary at the top of your form. Then, for each validator, set the ErrorMessage to the message you want to display, the Text to * , and the Display to Dynamic .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks again.
I think I am beginning to see what you mean - it will take some time for me to digest all your kind points. Yes, I can make those changes and see the results.
Do you mean apply CSS to ValidationSummary1, and not RegularExpressionValidator2, in order to add style to 'Please complete the Email field'?
|
|
|
|
|
You need to add style to both - the style on the ValidationSummary will apply to the summary messages at the top of the form, and the style on the individual validators will apply to the "*" that appears next to an invalid field.
I generally use a theme[^] folder with a .skin file to apply the same CssClass to all validators, and a CssClass to the ValidationSummary . That way, the settings are consistent across the site, and the style settings remain in the CSS file where they belong.
If you don't want to add a theme to your site, you'll need to set the CssClass on each validator and ValidationSummary wherever you use them.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes, there is a theme to the site: www.dimadayoub.net[^], so the style would need to be consistent.
Because space there is limited - the form is small - I was thinking of displaying the error messages in the form fields themselves.
My CSS is not that good to do that - not sure it can be done in HTML/CSS alone.
Grateful for your time.
|
|
|
|
|
hi Friends,
I want to create dynamic CSS for multiple ASP.NET controls , I have created required css but not able to create the css file where I want to store this css.
For eaxample:
I want to host multiple site with different css /template but same code. so I want to design separate css file based on site Id. so the need is that when a user set their css for all controls then we will save it in a separate css file.
Please tell me the way how can i do this.
|
|
|
|
|
Its very simple.
You can create a text file from your web page with your css code and save it as .css extension. (If unable yo create text file then please follow the link http://aspalliance.com/152_How_to_Create_a_text_file_in_ASP_NET_[^]
Basic process for set a css file
<head>
<link id="MyStyleSheet" rel="stylesheet" type="text/css" runat="server" />
</head>
But you need to set it from Code Behind
Then in your Page_Load , simply add a "href" attribute as below:
protected void Page_Init(object sender, EventArgs e)
{
var link = new HtmlLink();
link.Href = "~/styles/main.css";
link.Attributes.Add("rel", "stylesheet");
link.Attributes.Add("type", "text/css");
Page.Header.Controls.Add(link);
}
Hopefully its help you
|
|
|
|
|
What's the difference between 'model' and 'Model' in Asp.net MVC
|
|
|
|
|
Model represents the object (instance of the class) in your model .
For example, if your model is created as,
namespace Sample.Models {
public class Program {
public string Name { get; set; }
}
}
@model Program
<p>Model.Name</p>
This would write the value of Name in the paragraph.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|