MVC :: Academic: In-line Template For List Of LINQ Expressions?
Jun 5, 2010
If you still clicked this after seeing the title, you are probably like me and sometimes code just for fun. So, that's the spirit of this; all new approaches that solve this will be marked as answer.I have a template that I can't imagine ever using again, but use 5 times on a page. I wanted to DRY up my page a little:
[Code]....
While doing this, I realized that Lambdas confuse me - I had the feeling there was a much simpler way to code it.
View 3 Replies
Similar Messages:
Sep 30, 2010
I have a ListBox that contains userNames which is inputted by a user during run time. This number of items in the ListBox is dependent on the user's input. These userNames will then be used in a Lambda expression like this:
var vHandleResult = vHandleResult.Where(a => a.UserName.Contains("userName"));
This works fine when there is only 1 user in the ListBox but doesn't produce the correct results when there are multiple items in the listBox. I tried manually creating the expression which should be written as this:
var vHandleResult = vHandleResult.Where(a => a.UserName.Contains("userName1") || a.UserName.Contains("userName2") || a.UserName.Contains("userName3") || a.UserName.Contains("userName4"));
I tried forming the "a.UserName.Contains("userName") expression as a string which is dependent on the number of the items (using foreach) and then just plug in the resulting string in the expression but it seems that it doesnt accept string as an expression.
View 2 Replies
Jan 28, 2010
I have 2 tables; they have a many-to-many relationship. One is called Blog the other is Tag.
A Blog can contain a List of Tag objects. How can I go about getting all blogs that have a passed in tag name using lambda expressions?
View 1 Replies
Apr 25, 2010
In the "Regular Expression Editor" dialog in VS 2008 ( or 2005 for this matter ) ,
there is a list of "standard expressions" like :
"French phone number" , "French postal code" etc..
And of course there is an option to select a "Custom" and then enter your own regular expression.
Well.. I want to add a predefined expressions to that list . Like : "Israeli phone number" .
I don't want to enter it every time by selecting a custom value .
I want my developers in the team available items for them to choose.
Anyone knows how to alter that list ?
I've found some question about it on the web - and the answer given is that it's not possible .
View 1 Replies
Dec 4, 2010
Setting up the editItem template of a gridview. I have a template field with a dropdown list for editing. When the gridview goes into edit mode the dropdown list is displayed with all the right options but the current value of the field (pre-editing) is not the selected value of the dropdown list? How do I make that happen? I have a couple fields where the editItem template will use a dropdown list and I'm sure a user will not realize those values have changed and they will just edit what they intended to edit and save the changes, inadvertently also making changes to other fields.
View 3 Replies
Jan 23, 2010
I've a template in .zip format and wanted to add this template in "My Template" list for web based application.
I tried to copy this template to - C:Documents and SettingsusernameMy DocumentsVisual Studio 2008TemplatesItemTemplatesVisual Web Developer but it does not work but i can see my template for non-web based project.
View 1 Replies
Mar 26, 2010
I am working with asp.net web application,
I have a button and its text should contain academic year(eg: may 2009-may 2010) and it should be changed based on the current date and year .
View 2 Replies
Dec 22, 2010
I have a gridview. In that i am displaying links. See belw code
<asp:GridView
ID="grd"
AutoGenerateColumns="False"
[code]...
View 3 Replies
Dec 31, 2010
[URL]
Is it possible to have radiobutton control list in one row. Now it is in 3 rows.
View 3 Replies
Nov 5, 2010
What i have on my asp.net web page is a drop down list a add button and a mutiline text box, what I am trying to do is when user selcts a item from the drop down list it should populate in the multiline text box, I am able to achieve this partially with the multiline text box only showing the latest selection it does not remember the previous selection. Listed below is the code behing page
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
jtOperationsddl.DataSource = sqlServer.GetOperationsForDataEntry();
jtOperationsddl.DataValueField = "OperationID";
jtOperationsddl.DataTextField = "OperationName";
jtOperationsddl.DataBind();
}
}
protected void btnAddOperaions(object sender, EventArgs e)
{
listofOperations.Add(System.Convert.ToString(jtOperationsddl.SelectedItem));
String s = null;
for (int i = 0; i < listofOperations.Count; i++)
{
s = s + System.Convert.ToString(listofOperations[i]);
}
jtOperationsmltbx.Text = s;
}
Every time I hit the add button the List becomes empty
View 7 Replies
Mar 21, 2011
How can I have my Radio Button List have a line seperating each item?
[Code]....
View 5 Replies
Jan 19, 2010
I have a list<string> which have a bunch of Employee Names
Second, i have a list<Employee> (employee object )
Employee.Employee Name
Employee.status ........
Now
how can i filter list<Employee> , so that i can have the list with only the names from the List<string>
View 8 Replies
Apr 7, 2010
I have a query that gives me the average number of days between 2 dates in the database. It gives an error saying line does not reconize the subtract method. What is the best way to do this, i prefere not to have to get the whole table as a list and loop though.
Using em As EE.EclipseEntities = New EE.EclipseEntities
Return em.OrderLines.Where(Function(w) w.Received_Factory_On.HasValue) _
.Average(Function(a) CDate(a.Received_Factory_On).Subtract(CDate(a.Sent_Factory_On)).Days)
End Using
View 2 Replies
Oct 11, 2010
i have a dropdown list in edit mode and read only mode. If users upload pictures, i want them to chose a category for the uploaded pics and display it in a gridview as below.(See Picture below). When i include "SelectedValue='<%# Bind("CategoryID")" in edit and item template mode, i get this error "'PictureReadOnlyCategories' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value "
When i removed the "SelectedValue='<%# Bind("CategoryID")" from edit and item template, i get the result on the pic below(screenshot). If u can see the pic below the category is not selected, it just display the -- No Category -- even when i chose a category for the pic. I want when a pic is uploaded and i category chosen, to display on the gridview. The code for the error message is below:
<EditItemTemplate>
<asp:DropDownList ID="pictureEditCategories" runat="server"
AppendDataBoundItems="True"
DataSourceID="categoriesDataSource"
DataTextField="Name" DataValueField="CategoryID"
SelectedValue='<%# Bind("CategoryID")
%>' ValidationGroup="PictureEdit" >
<asp:ListItem Value=""
Text="--No Category -- "/>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:DropDownList ID="PictureReadOnlyCategories" runat="server"
AppendDataBoundItems="True" DataSourceID="categoriesDataSource"
DataTextField="Name" DataValueField="CategoryID" Enabled="False"
SelectedValue='<%# Bind("CategoryID")
%>' ValidationGroup="PictureEdit"
>
<asp:ListItem Value="">-- No Category --</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Title"
SortExpression="Title">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" EnableViewState="False"
Text='<%# Bind("Title") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4"
runat="server"
ControlToValidate="TextBox1"
Display="Dynamic"
ErrorMessage="must enter a title"
ValidationGroup="PictureEdit"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Title")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description"
SortExpression="Description">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Columns="25" Rows="4"
Text='<%# Bind("Description")
%>' TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5"
runat="server"
ControlToValidate="TextBox2"
Display="Dynamic"
ErrorMessage="you must enter a description"
ValidationGroup="PictureEdit"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Description")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date Added"
SortExpression="UploadedOn">
<EditItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("UploadedOn")
%>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("UploadedOn")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:ImageField DataImageUrlField="PictureID"
DataImageUrlFormatString="~/UploadedImages/{0}.jpg"
HeaderText="Image"
ReadOnly="True">
<ControlStyle Width="100px"
/>
</asp:ImageField>
</Columns>
<EditRowStyle BackColor="#2461BF"
/>
<FooterStyle BackColor="#507CD1"
Font-Bold="True" ForeColor="White"
/>
<HeaderStyle BackColor="#507CD1"
Font-Bold="True" ForeColor="White"
/>
<PagerStyle BackColor="#2461BF"
ForeColor="White" HorizontalAlign="Center"
/>
<RowStyle BackColor="#EFF3FB"
/>
<SelectedRowStyle BackColor="#D1DDF1"
Font-Bold="True" ForeColor="#333333"
/>
<SortedAscendingCellStyle BackColor="#F5F7FB"
/>
<SortedAscendingHeaderStyle BackColor="#6D95E1"
/>
<SortedDescendingCellStyle BackColor="#E9EBEF"
/>
<SortedDescendingHeaderStyle BackColor="#4870BE"
/>
</asp:GridView>
View 1 Replies
Nov 10, 2010
I am using a DetailsView Control and have a "MemberStatus" field.
When using the templates in edit mode, I am using a dropdownlist to change the member status.
e.g.
<asp:TemplateField HeaderText="Member status:" InsertVisible="False" SortExpression="MemberStatus">
<EditItemTemplate>
<asp:DropDownList ID="ddlMemberStatus" runat="server" DataSourceID="adsMemberStatus" CssClass="eitField" DataTextField="MemberStatus"
DataValueField="MemberStatusID" Width="120px" SelectedValue='<%# Bind("MemberStatusID") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("MemberStatus") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
What I would like to achieve is, if the MemberStatus is changed during edit mode, e.g. from "Active" to "Deceased"
I would like to enable certain fields e.g. txtBoxDateDeceased, and attach a RequiredFieldValidator for the textbox field.
View 2 Replies
Aug 6, 2010
how to handle selected index changed event for dropdown list in footer template in grid view
View 2 Replies
Mar 26, 2010
I have a web form for handling invoices which has a form view. When I'm in insert item template, I need to have various fields. Some of them are contract number, invoice number, register date and other that are easy to handle. But there is a dropdown list related with a table of prices (the table has price name, price initial payment, number of payments, amount of month fee and so on). So, when the dropdown is selected, fields related with price should get their values from price table, and then the user decides to keep them or type in new values. How can I get it done? Should I use a Dynamic populate extender or type all the code behind using SelectedIndexChanged method to populate price related controls?
View 2 Replies
Feb 18, 2011
I have below class and function. Could I use LINQ to select from class list?? What the syntax should be??
class ItemsPromo
{
public long itemID;
public long promotionID;[code]....
View 1 Replies
Nov 23, 2010
I have declared a simple class
[Code]....
And Pass some values to it :
[Code]....
Then I use Linq to select rows :
[Code]....
How I can enumerate it?! I used this, but it has error
[Code]....
View 3 Replies
Aug 11, 2010
[Code]....
say i have the code above which adds a single row to a list how would i add all the information in a linq query or a var to the list?
View 2 Replies
Nov 6, 2010
There is a session on a web form that holds the holidays of a year.I just intend to remove any repetitive days.... but couldn't get index of item in list.
Protected Sub PersianDateCalendar1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles PersianDateCalendar1.ValueChanged
[Code]....
End sub
View 3 Replies
Feb 10, 2011
I have a no. of records being inserted in a List<>.I have IQueryable returning more then one recordI want to check whether the records IQueryable returns are present in the list or not?
View 1 Replies
Dec 8, 2010
I have a class Trans with various properties, including a boolean named Deleted.I have a generic list of Trans that are loaded from the database. I want to use linq to set all the Trans in this list to Deleted. Can I use linq to do this?
[Code]....
View 3 Replies
Mar 5, 2010
I have list of words. I type in a word misspelled. Can I query the list using linq to get words that sounds like (soundex) the misspelled word?
View 2 Replies
Nov 23, 2010
I have grid view which databind from object datasource. my problem is i want to disply dynamic dropdown list on edit template based on the id which has in grid view. but still i can't figure out a way to do this.
View 1 Replies