Select Property Based On String Value?

Feb 1, 2010

I got an unusual problem. The solution is most likely very simple or completely impossible. I want to dynamically select a property based on a string value. I am using LINQ which automatically creates a class for each table. The actual columns in the table become properties of the class. I need a different column based on the current culture settings as the different columns contain translations. For example, if I want to set the text of a hyperlink to English I choose the EN column as follow:

[Code]....

View 3 Replies


Similar Messages:

Forms Data Controls :: Select A Grid Row Based On Query String Data?

Jan 13, 2010

I need to know how can I select a gridview row based on a query string data. In my case, the query string will contain the id that exist in the Table related to that grid. Is there a way to do this from the code behind? In other words, if I click a link with that specific query string, can I open the page and tell my grid to select a specific row based on the table row id?

View 1 Replies

Create A Simple String Array With Data Retrieved From A Select Statement(SELECT Firstname FROM Customers?

May 29, 2010

i'm trying to to create a simple string array with data retrieved from a select statement(SELECT firstname FROM customers , for ex.)

View 6 Replies

SQL Deliminator String - Iterate Through The String And Do Inserts Based On The Value?

Jul 1, 2010

I have a string with values seperated by the ";" character I want to iterate through the string and do inserts based on the value is there an article or script that would point me in that direction. Im doing this in sql express

View 3 Replies

C# - How To Get A Property Value Based On The Name

Apr 1, 2011

is there a way to get the value of a property of a object based on its name?

For example if I have:

public class Car : Vehicle
{
public string Make { get; set; }
}

and

var car = new Car { Make="Ford" };

I want to write a method where I can pass in the property name and it would return the property value. ie:

public string GetPropertyValue(string propertyName)
{
return the value of the property;
}

View 3 Replies

MVC :: Assigning A Cssclass Based On A Model-property?

Dec 6, 2010

I want to assign a stylesheet-class to a <div> element. The cssclass I want to use depends on the property 'Level' which is defined in de ViewModel.

I want to have something like this:

<div class="dashboardlevel" + <%= Model.Level %>>

But this doen't work.

View 2 Replies

C# - How To Break An Object Into Chunks Based On Some Property

Apr 22, 2010

public class InvestorMailing
{
public string To { get; set; }
public IEnumerable<string> Attachments { get; set; }
public int AttachmentCount { get; set; }
public long AttachmentSize { get; set; }
}

i have an IList<InvestorMailing> mailingList. if the attachment size is greater than x, then i need to split my object into chunks. is there an easy linq-y way to do this?

[Code]....

View 3 Replies

Web Forms :: Set Variable Based On CheckBox Checked Property In C#?

Mar 1, 2013

I used below code fo radiobutton to inserting data in database

string price = RadioButton2.Checked ?"1": "null";
SqlCommand _cmd = new SqlCommand("insertproduct2", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cn.Open();
_cmd.Parameters.AddWithValue("@Price", price);
_cn.Close();

Now I use same code for checkbox I want if users checked chekbox in table insert "1"

else insert "Null" but when I wrote below code

string Off = checkbox1.Checked ? "1" : "null";

it make error Under checked attribute it didn't recognize Checked attribute here. what should i do?

View 1 Replies

Split The Input String Based On The Separator List Passed / String Separator

Apr 7, 2010

Split the input string based on the separator list passed. Returned string list should have separators in it.

.NET API needs to be implemented

string [] SplitWithSeparators( string inputText, string[] separators)

Input

inputText: passed string

RAMESH EMPCODE 001 SURESH EMPCODE 002 GIRISH EMPCODE 003
Separators: passed string[]
string [0] : TRINATH
string [1] : SHARATH
string [2] : SRIDHAR

THIS OUTPUT I SUPPOSE TO GET

Output

string [0] : TRINATH EMPCODE 001
string [1] : SHARATH EMPCODE 002
string [2] : SRIDHAR EMPCODE 003

View 5 Replies

Web Forms :: Get User List Based On Specific Profile Property

Sep 4, 2010

I am trying to query a DB and get a list of users based on a specific boolean property stored in the aspnet_profile for that user. I am aware that it wasn't possible a few years ago [URL] but was wondering whether that had changed in recent releases, or it was still not possible without trawling through the entire list of users and testing them one by one. (My DB may become way to big for that.)

View 3 Replies

Update Design-time UserControl Interface Based On Property Value?

Jan 14, 2010

I've created a UserControl with the following public property:

[Browsable(true)]
public string Text
{
get { return pnlLookupTable.GroupingText; }
set { pnlLookupTable.GroupingText = value; }
}

pnlLookupTable is, as you may have guessed, a Panel control. I can change the value of the Text property in the Properties window and it's reflected in the markup like it should be. However, the design view of the UserControl inside a page does not show updated GroupingText for the Panel. How can I get this to happen?

EDIT:

By request, here is the entire class to which that property belongs. You can see there's nothing special going on:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

[Code]....

And here's the relevant part of the .ascx file:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="LookupTable.ascx.cs" Inherits="LookupTable" %>
<asp:Panel ID="pnlLookupTable" runat="server" GroupingText="Lookup Table">
<%-- Irrelevant content here. --%>
</asp:Panel>

I have changed some identifiers and other trivial things to protect the proprietary nature of the code.

I should also reiterate that I'm looking at a Web form in design mode that has my control added, and I'm changing the Text property. I want to see the change to the Panel's GroupingText visually in the designer.

View 2 Replies

C# - Composite Control Property That Allows Coder To Select From Options?

Mar 16, 2010

The question is in the title but to make it clearer when you use a normal server control like

<asp:textbox />
<CC1:CtrlArticleList SortBy="Title" ID="compositeControlArticleList" runat="server" />

the properties of textbox allow you to select from a dropdown list (eg visibility=...true or false). How do I replicate this in composite control?

Added code since question asked:

[code]....

View 1 Replies

How To Select A Gridviewrow Based On Textbox Value

May 20, 2010

I have a gridview that is selectable. Below it I have a dropdownlist and a textbox. The dropdownlist has the options for each column in the row(I am using an ajax autocomplete extender that checks for related values in the textbox based of which dropdownlist value is selected.) I want to take that a step further and see if I can select a row based on what is in the textbox on the textchanged event. Right now im playing around with using a datatable and then filling a string[] of whatever column the dropdownlist is selected on.
protected void txtFilter_TextChanged(object sender, EventArgs e)
{
DataTable dt;
SqlCommand cmd = new SqlCommand("SELECT * FROM General", csbg2);
SqlDataAdapter da = new SqlDataAdapter(cmd);
dt = fillDatatable(cmd, da);
string[] items = new string[dt.Rows.Count];
switch (ddlEducation.SelectedValue)
[code]...

View 1 Replies

Forms Data Controls :: Change Property Value Of An Object Based On A Database Value?

Nov 18, 2010

I'm new to ASP so this may seem so simple but I cannot work it out.

I am trying to create a script that changes its output based on a range of values. Here is what I mean:

I have a MSSQL database with an ASP scripted website that reads it and displays the data in a table. One of the columns in the database is a percentage and I want that column in the web page to have a background colour based on the figure outputted.

So each cell may be a different colour. If the number is between 0 and 30 then red background, 31 to 70 orange etc.

At the moment I have the database output script looking like this:

[Code]....

How can I implement what I have outlined above?

View 1 Replies

ADO.NET :: LINQ Query To Select Objects Containing Collection Of Keyword In A Property?

Dec 16, 2010

I'm new to linq. here is the scenario i need to write query for.I have a "Candidate" table with a varchar property "Skill"I have the table OR-mapped with LINQ to SQL on dbml file. Now I want to write linq query that:Selects all Candidates that have skill containing any of the keywords from ("asp.net","php","java")

View 1 Replies

SQL Server :: How To Select Population Based On District

Dec 12, 2010

How to select population based on district?

Ex table: Country, District, Population, State

View 5 Replies

Web Forms :: How To Add String Property

Mar 20, 2010

I have this tag in my webfom

<img id="takeimg"
alt=""
src="images/i.jpg"
data-zoomsrc="images/i.jpg"
border="0"
runat="server"
width="130"
height="90"
/>

this works fine, whenever i mouse over on image even its works perfectly. problem is when i pass it dynamically as given below,it doesnt work, how to fix this how can i add "data-zoomsrc" dynamically. I can set Src property dynamically, but how can i set data-zoomsrc.

<img id="takeimg"
alt=""
src="<%=getimg %>"
data-zoomsrc="<%=getimg %>"
border="0"
runat="server"
width="130"
height="90"
/>

View 1 Replies

C# - Get Control's Property Value From String In .net?

Jul 31, 2010

I need to loop through all controls on ASP.NET webpage. In configuration file I have a list of control types and their properties which will I handle in some way. Now, I am interested in following: how can I get that needed property, when all I have are strings, ie names of types of controls and names of their respective properties.Here is example: In config file I have strings:

controltype = "label" propertyname = "Text"
controltype = "Image" propertyname = "ToolTip".

so I have something like this in my code:

List<Control> controls = GiveMeControls();
foreach(Control control in controls)
{ [code]....

how to develop getPropertyValueFromProperty()?

View 2 Replies

Select Query In LINQ Based On Foreign Table

Mar 2, 2011

I have 2 Tables , OrderDetails and Requests In my LINQ to SQL dbml file. OrderDetailsID is a foreign key in Requests Table. I want to write the query to get the sum of UnitCost from OrderDetails based on OrderId. And If there is a row in Requests Table for each OrderDetailsID, and the Requests.Last.RequestType="Refund" I want to reduce the total refund amount from the main sum otherwise If there is no row based on OrderDetailsID, add to sum. Here is the way I implement that. I am looking to prevent using "For each".

iRefund = (From od1 In dc.OrderDetails _
Where od1.OrderID =1 _
Select od1.UnitCost).Sum
Dim objOrderDetails = (From od1 In dc.OrderDetails _
Where od1.OrderID =1 _
Select od1)
For Each OrderDetail As ORM.Entities.OrderDetail In objOrderDetails
If Not OrderDetail.Requests Is Nothing Then
IF OrderDetail.Requests.Last.RequestType="Refund" Then
iRefund -= OrderDetail.UnitCost
End If
End If
Next

View 1 Replies

SQL Server :: Select Records Based On Previous Record?

Mar 23, 2011

If I have records in a table in this order:

Id - Date - Type
1 - 2011-03-01 - 1
2 - 2011-03-02 - 0
3 - 2011-03-03 - 0
4 - 2011-03-04 - (-1)
5 - 2011-03-04 - 0

Can I somehow select the records between a record having type 1 and type -1 without using a cursor,for example the records with ids 1-4 in this example?

View 9 Replies

SQL Server :: Select Query Based On Two Fileds With Different Column

Dec 21, 2010

This is my Table structure:-Table1

Field1 Field2 Age

Dean Chen 20

Janel Wast 25

ann Miller 20


I used this select statement

select Field1+' - '+Filed2 from Table1

and i binded this in dropdownlist

now on selecting dropdownlist i need to show age in label. so how would be my select statement... to show age base on Filed1 and Filed2

View 6 Replies

Web Forms :: Programmatically Select Item In DropDownList Based On Text Value

May 7, 2010

Here's what I want to accomplish: I have two .aspx pages, the first page with a ddl to select a vendor (SelectVendor.aspx), and one to add a vendor (NewVendor.aspx), if it's not in the first one. If a user adds a new vendor on the NewVendor.aspx page I want the page to automatically redirect back to SelectVendor.aspx and have the ddl automatically select the new vendor that was just added. Here's where I'm at so far: If a vendor is not listed in the ddl on SelectVendor.aspx, a user can click a button to navigate to a page to add a new vendor (NewVendor.aspx). On NewVendor.aspx the user types the name of the new vendor in a textbox and clicks an insert button to add the new vendor, then the page is automatically redirected back to SelectVendor.aspx with the new vendor name added to the QueryString. For example, let's say a user adds a vendor name "Best Vendor": The page is redirected back to SelectVendor.aspx as "SelectVendor.aspx ?vendor=Best Vendor"Now all I need from here is to have the ddl programmatically select the new vendor by the text value in the QueryString.

Here is the code that I'm having trouble with from my Page_Load routine for SelectVendor.aspx:

[Code]....

View 7 Replies

Web Forms :: Select User From Drop Down List Based On Login Name

May 26, 2010

I have a drop down list bound to a column in a database. If a user logs into the website using the standard login controls, I want the drop down list to automatically select there name from the list. here is the code that doesn't work

[Code]....

The error orrcurs here:

[Code]....

Which intellisense says "Property Access must Assign to it's property or use it's values". Do I have the code all wrong? Also, as a side question, I don't understand why I have to use the TryCast find control option to find every control to use them. Even in the Page_Load if I type in DropDownList1 it says it's not declared.

View 3 Replies

Select Form Elements In JQuery Based Upon An HTML Table?

May 13, 2010

I am working on some ASP.NET web forms which involves some dynamic generation, and I need to add some onClick helpers on the client side. I have a basic outline of something working, except for one huge problem.

There are multiple HTML tables, each generated by a different ASP.NET web control. Each table can contain overlapping field names, which is causing a problem with my JQuery click event handlers. The click event handler is linking to unintended form fields in addition to the intended form field.

I have provided a simplified sample version of the code below. This code is trying to set the value of textbox box1 when a particular radiobutton is selected in the table with id=thing1. Obviously, the jquery code will be triggered for the form fields in both tables.

The tables are dynamically added to the webpage based upon different conditions. It is possible that no tables will be loaded, only 1 table, or both tables might load. In the future, other tables could be added. Each table comes from a different .net web control.

Other than renaming the form fields to make sure they are unique across all user controls, is there a way to have JQuery act only on the intended form fields? In other words, could the table ID be incorporated into the JQuery code in a manner that does not become a nightmare to maintain later?

[code]....

View 2 Replies

Forms Data Controls :: Select Gridview Row Based On Session Value?

Aug 15, 2010

As the post subject I have a gridview;

the question is how can I select the row (not change bg color) during page load dedect a session value ?

View 8 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved