Storing Data In A Generic Field?

Aug 24, 2010

I'm having a couple basic generics problems. Basically, I'm trying to identify a piece of content by two indexes.

1) I need to store the content in the class, so I need to create a class variable, classTableCellContent, to store it in. Therefore I need to create one, requiring me to constrain the generic type "where ContentType : new()". However, when I attempt to consume this type with a string, e.g. TableCell<string>, it throws a compiler error "The type 'string' must have a public parameterless constructor in order to use it as a parameter blahblahblah..."

2) I need to accept input, so I have an add function. However, when I try to indicate that the third parameter is the same data type, i.e. ContentType, the compiler seems to believe that I'm creating a "new" data type with a poorly chosen name that hides the original data type declared in the class declaration. I'm sure this must be something stupid I'm missing. All I want to do is accept an input variable of the generic type in a function and store it in the class for later use.

Here's the code. I've even highlighted the two lines that seem to be throwing the errors.

Code:

[code]....

View 11 Replies


Similar Messages:

DataSource Controls :: Storing Required Field Names In Web.config?

Feb 2, 2010

I am writing an app that has a bit of process flow to it. On the save of a record, I need to check some fields to make sure they are not null. If they are not null, I will update a 'SectionComplete' field to true.

The thing is, I would like to store my fields in the web.config. So, I would like to have a string in the appsettings section that has a list of field names that are required. Then in my method, I would call these fields out and check each one for the specific record id, and then update the database.

I would like to do this in the web.config so we could add/remove columns without having to redeploy.

For example: my required fields are name, id, and phone. For section one to be labeled complete, all of these fields would need to be not null.

web.config would have this entry:

<add key="Stage1Fields" value="name, id, phone"/>

View 4 Replies

Crystal Reports :: Storing Picture Information In An Image Field?

Sep 12, 2010

in sql i am storing picture information in an image field.

in vs2005crystal report i added this image field.but image is not showing.

View 1 Replies

Storing A Uploaded File In DB Or Storing It In Filesystem?

May 11, 2010

I have a File Uploader in my ASP.NET application Using C#, we can upload any type like images, documents, pdf etc.

I m storing it in the Filesystem and having only the Name of the File in DB.My doubt is can we store the entire file, images in DB. State me Which is good practice and why we need to use it.

Either file System Storage or SQL DB Storage.

View 4 Replies

Custom Server Controls :: Using The Generic Type 'System.Collections.Generic.IEnumerable' Requires '1' Type Arguments

Nov 25, 2010

I'm trying to create a control out of a class I found, and one of the overridden functions is the following:

protected override void PerformDataBinding(IEnumerable data)

However, when I try to build the control I'm getting the error as shown in the subject. I've tried searching, and it seems the signature for the original function matches the one I have, and all other solutions I've seen uses the same signature.

View 3 Replies

Difference Between Generic And Non - Generic Collection?

Oct 30, 2010

What is the difference between generic and non-generic collection?

View 1 Replies

Forms Data Controls :: How To Display A Checked Checkbox When Field Value=1 And Unchecked When Field Value=0

Apr 22, 2010

I am using a GridView Control to display multiple fileds with 0's and 1's.

I am using template fields where CheckBoxes are used.

Where exactly and how do I apply the Logic to get a checked CheckBox when field Value=1 and unchecked CheckBox when field Value=2 .Also some times to be able to write a YES where fieldValue=1 or NO where filedValue=0

Do I apply this logic using asp or C#? How?

View 2 Replies

Forms Data Controls :: Disable/Invisible Field In Gridview Based On Another Field?

Jul 9, 2010

I have 2 fields in my gridview one called ScriptType the other BagNo, when a user click the edit button, I would like the BagNo filed to be disabled if the ScriptType field is = "TTA" and enabled otherwise. How can I do this?..something along these lines see below..I am using VB..

[code]...

View 14 Replies

Forms Data Controls :: A Required Input Field DropDownList If Old Records Have Null In This Field?

Apr 1, 2011

I have a DetailsView on the page and I have made one of the fields a TemplateField. In the EditItemTemplate and InsertItemTemplate I have a DropdownList that is databound to a table in my Sql Server database. I wanted to add an initial value to the DropdownList
namely "- select -" .

I set the AppendDataBoundItems property to true and added the initial value as a ListItem.Markup of the DropdownList

<asp:DropDownList ID="DropDownList_HP" runat="server"

AppendDataBoundItems="True" DataSourceID="SqlDataSource_HP" [code]...

This works fine for new input. The problem is however that the database already has records that were entered through a Windows Application and many of these records has a null value in this field and exceptions are thrown when I tried to open these records
and the system tried to set the SelectedValue of the DropdownList.After some more searching I found this help

http://msdn.microsoft.com/en-us/library/ms366709.aspx

So I changed the ListItem in the DropDownList markup to the following:

<asp:DropDownList ID="DropDownList_RefHospDV4" runat="server"

AppendDataBoundItems="True" DataSourceID="SqlDataSource_RefHosp" [code]...

This now solved the problem of opening a record where the value is null in the database, BUT now the RequiredFieldValidator is not validating anymore to make sure that a databound item is selected for this field and not the initial value "- select -". So basically now it is not checking anymore to see if valid input has been entered for the DropDownList and it accepts "- select -" thus it acts as if the field is not a required field anymore.

In short what is required is that I want to make sure that the user enters a valid selection in the DropDownList, but it must also cater for old records that do not have this field entered yet so that those old records can be opened in the DetailsView .Opening Old records (with null in that field):When these old records are opened in the DetailsView the DropDownlist should show "- select -" when the value in the database is null.

Saving records (old or new records):When saving the record in Insert mode or Update mode the RequiredFieldValidator should show that a valid input is not selected if the DropDownList is still on "- select -".

View 1 Replies

Forms Data Controls :: How To Use A Field Value In Another Field In Gridview

Dec 19, 2010

I have a grid view, and I add new column as a hyper link field, I want the navigationURL for this field to be Pageexample.aspx?ID=other field value like this

[code]...

is that possible ?

View 2 Replies

Forms Data Controls :: Retrieving Data From A Web Serivce And Storing The Data Into A Dataset?

Aug 27, 2010

I am retrieving data from a web serivce and storing the data into a dataset.

I'm then populating a gridview with the data from the dataset.

Before each row of data is displayed on the website, I need to check and make sure the user has proper permissions to view that data.

Can this be done with a gridview(or any other .NET data control)?

Or would I need to loop through the data manually, and then write each row out manually?

View 3 Replies

Forms Data Controls :: Pull Data Coming From Generic List In OnRowDataBound?

Feb 15, 2010

I need to "massage" the data a little during OnRowDataBound. When I used DataTable as my data source for my GridView, I could do the following:

[Code]....

How do I grab the row data if I'm getting it from List<Product>?

View 3 Replies

Forms Data Controls :: How To Read ListView Data Into Generic List

Aug 19, 2010

I have a ListView which is filled by generic list of type MyClass. I can easily bind data from this list into ListView. But I have problems with reading data in opposite direction. This is my class:

[Code]....

I have also generic list of type MyClass:

[Code]....

Finally I bind data to ListView this way:

[Code]....

My ListView template:

[Code]....

How can I read data from ListView into my List list?

The operation of reading ListView data into List generic list should begin after clicking the button "GetData".

I saw the following advice:

[Code]....

but it does not work - the DataItem property of each Item of ListView has null value. The point is that I have generic list with data. I am binding this data into ListView which can be edited by user. After that after click Save or GetData data from ListView is read into generic list of MyClass type.

View 8 Replies

Data Controls :: Check If Data Exist In List Generic Collection Using C#

Apr 19, 2014

i want to check my collection so i can add a new customer as long as the username does not exist in the collection i do not want 2 customers to be able to have the same username.

i have been trying many different things to try to get this to work but i am not exactly sure what i should be doing I have a aspforum and collection C# class of the list.

here is some things that i have tried

CustomerExists()      i also have a collection of List<Customers>
 //HERE IS MY EXISTS METHOD
public static Boolean IfCustomerExists(string login) {
List<Customer> theGuy = Collections.Customers;
bool exist = false;
foreach (Customer customer in theGuy)

[Code]....

View 1 Replies

C# - Storing JSON Data In Db?

Jan 3, 2011

I'm trying to store data from fb wall into database.

My *.cs code

public ActionResult GetWall()
{
JSONObject wallData = helper.Get("/me/feed");
if (wallData != null)
{
var data = wallData.Dictionary["data"];
List<JSONObject> wallPosts = data.Array.ToList<JSONObject>();
ViewData["Wall"] = wallPosts;
}
return View("Index");
}

Which gets posts from fb wall. And then I have an *.aspx file, which "breaks" my wallposts into pieces (objects) or whatever you like to call them.

foreach (Facebook.JSONObject wallItem in wallPosts)
{
string wallItemType = wallItem.Dictionary["type"].String;
//AND SO ON...

What i'm trying to say is that I can access to elements inside fb JSON.

Is there a way i can access to the JSON elements inside *.cs file. Or is there a way I can store elements inside the *.aspx file to db?

View 2 Replies

Forms Data Controls :: Display Data Using Generic Web Handler?

Feb 4, 2011

I want to bind gridview partially for e.g. show only 10-20 records first and next 10-20 records after scrolling on panel. For that purpose i want to fill gridview using generic handler in asp.net.

Actually i want to know how to return dataset or datatable or xml using generic handler in asp.net.

View 2 Replies

Data Controls :: How To Use Generic HTTP Handler For Saving Data

Mar 26, 2016

How I can save data into database using this method JSON Generic HTTP Handler example in ASP.Net?

View 1 Replies

C# - Storing User Data In Cache Vs Querying Data Everytime?

Feb 1, 2011

If I store all my user info, upon login, in cache and just have a "my account" page that displays the user info from cache, is that a good practice? I'm wondering if a person changes his email or does any type of database modification then the cached variables will be the wrong ones. If I have to update the cache variables every time something happens to the database, is this even a good practice compared to just querying the data whenever needed?

View 3 Replies

C# - Storing Complex Data In A List?

Sep 27, 2010

I'm working with a product called SiteFinity.I have a class which looks like so:

public class Categories
{
public IContent oContent {get; set;}

[code]...

View 2 Replies

Storing Contextual Data During A Request?

Oct 2, 2010

I am writing an ASP.NET application that initializes some contextual data based on stuff sent through the Request object. How should I be storing this so that it is only visible to objects dealing with the request?

Essentially I have an HttpModule that looks at the request, and does something based on the incoming data:

public void OnBeginRequest(object sender, EventArgs e){
if((sender as HttpApplication).Request.Url.Host == "something"){
// Store some extra information here
}
}

And then I want to retrieve the data later on in the pipeline, in a view

<%: somehowGetRequestSpecificData.MyProperty %>

How and where should I be storing that stuff?

View 1 Replies

C# - How To Make A Generic Data Access Class

Aug 5, 2010

ASP.net C# 3.5 Framework, working in Visual Studio 2008 currently.

What I want is a Generic Data Access Class. I have seen several of them but what I want is to see one that I pass the Connection String and the SQL statement and it will return a List of Objects or when only one item an Object or when no response needed a boolean to let me know if it succeeded?

View 3 Replies

Storing Configuration Data In .NET Than The Web/machine Config?

Jun 24, 2010

We have a large multi tenanted website which requires thousands of lines of web.config to support it. As the system grows we are finding it more and more difficult to manage this configuration file.The system currently in place uses XSLT to generate the config but this solution seems to involve a lot of duplicated code (we have 12 deployment environments).

I am leaning towards putting the configuration data in the db so we can be sure that it's deployed with the application and that our release notes don't require the IT guys messing around with XML

What are better solutions we could use?

View 3 Replies

SQL Server :: Storing Form Data In Database?

Nov 29, 2010

i made an asp page for registration with the following fields name, address etc. i also created database in sql server. how to save these field data in my database.

View 2 Replies

Storing Data From Database In Static Property?

Mar 25, 2011

I have got an ASP.Net website, where the data is brought in from ISeries.The data connection to ISeries is quite slow and the speed is quite important for this website. Because of the slow speed of data retrieval from ISeries, I want to make as less database connections as possible.So, I was thinking about storing tables from the database which rarely changes as static properties in my website. Whenevera user logs in I submit a thread which refreshes the data in the static property. Is this approach correct? If not, what are the problems with this approach and what are the possible alternatives?

Example:-

For list of ports, I submit the below thread when user logs on:-

[Code]....

In class Ports, there are 2 methods -

one for populating the static property PortList, and the other checks if the thread is alive and waits for the thread to complete and retrieve the list of ports, once it is complete. The second method is the one which I use in my application whenever I need the list of ports (populating a dropdown, etc).

[Code]....

View 1 Replies

Storing Large Arrays Of Persistent Data?

Oct 16, 2010

I have developed an asp.net application that I developed using visual studio express 2008.

With this application, I have 20 sales items. I can sell 10 of each item each day. Customers can order the items in advance but once an item has more than 10 orders for the day then I can not sell any more of the items for that given day. If a customer tries to order another item after 10 has already been ordered then I must tell them that no further items of that kind are available. So for each day there can be possible 200 orders total (20 items x 10 sales). Customers can order months in advance...

So, my question is what kind of storage device do I use to keep track of this kind of data? Database or application variable or other?

View 3 Replies







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