.net

How to convert a DataTable/DataSet into a ObjectDataSource

I have a GridView that's tied to an ObjectDataSource. I have a method that returns a DataTable. How do I feed the DataTable to the ObjectDataSource so that the GridView is updated in code? Example: protected void Page_Load(object sender, EventArgs e) { MyClass obj = new MyClass(textbox.Text); DataTable dt = obj.GetData(); ...

How to pass in runtime a index of row for DataView ?

Hello everyone, I have an question, On my page i have a DataView control, I also have a button that has CommandArgument. I know i can read the DataView as : myDataView.Rows[i].FindControl("FaqQuestion"); I want to add index value in runtime to the CommantParameter, so when i go to the Function onCommand i will know exactly from what ...

Determine if ASP.NET application is running locally

I want to know if there is a recommended way of determining if an asp application is running locally. At the moment I use the Request object and do a string search for localhost or 127.0.0.1 on the server variable but this has several limitations. The biggest one being that the Request object is not always available when I need it. ...

How do I save an entity for the first time that requires another pre-existing entity to be attached to it

I need to save a Company entity to the database as a new entity. In order to do this I need to associate a CompanyType entity to the Company entity. I can't save the Company without do this. Do I attach the newly created company to the context and then attach the company type entity to the company and then save my results? This code ...

"Collapse" Panel Control Borders for WinForms

Is there any way in WinForms to emulate border-collapse from CSS? Imagine this: You have a Panel control with a border of FixedSingle, giving it a 1px black border, docked to the top of a form. You add a second Panel control with the same border and also docked to the top, in effect stacking that Panel underneath the first Panel. The pr...

How to pass in runtime a index of row for ListView ?

Hello everyone, I have an question, On my page i have a ListView control, I also have a button that has CommandArgument. I know i can read and find a control in the ListView as : ListView.Items[i].FindControl("controlname"); and my button in ListView is like that asp:Button ID="WisdomButton" runat="server" CommandName="UpdateWisdom...

.Net: Using a Webservice as an interface for a Data Access Layer

I am currently doing a CRUD project for school and basically they want us to have this kind of structure (3 projects): Class Library Contains all the Data Access logic (Retrieving the data from the database with either Linq of standard ADO.Net) Web Service Having a refere...

System.IO.Stream disposable with a reader

Can't remember where I read it, but I remember a MS guy saying that once you create a reader around a System.IO.Stream, then the stream is not longer responsible for the disposal of the stream. Is this true? Can someone confirm this? Maybe provide a reference. This means the outer using in this code is redundant using (var s = new Fil...

Best way to call .NET classes from PHP?

What are the best options for connecting PHP apps to logic located in .NET libraries? PHP, since v5.0, supports a DOTNET class that is supposed to let me invoke .NET logic from a PHP script. But it seems there are many problems - I've not been able to get it to work reliably, with arbitrary .NET classes. The doc is sort of slim and wha...

When should one use Environment.Exit to terminate a console application?

I'm maintaining a number of console applications at work and one thing I've been noticing in a number of them is that they call Environment.Exit(0). A sample program would look like this: public class Program { public static void Main(string[] args) { DoStuff(); Environment.Exit(0); } } I don't understand ...

.Net HttpWebRequest.GetResponse() raises exception when http status code 400 (bad request) is returned

I am in a situation where when I get an HTTP 400 code from the server, it is a completely legal way of the server telling me what was wrong with my request (using a message in the HTTP response content) However, the .NET HttpWebRequest raises an exception when the status code is 400. How do I handle this? For me a 400 is completely le...

.NET Framework 3.0 Service Pack 1

Hello everyone, I am so confused that there is no 64-bit .NET Framework 3.0 Service Pack 1 download? If there is, could anyone send me a link please? My OS is Windows Server 2003 x64. Thanks. thanks in advance, George ...

Hello OS with C# & mono?

Is there a way to identify in which OS we are running mono, with C# code? Some sort of Hello World, but instead of using a fixed string as an output use the current OS? ...

How to learn the .NET Framework

Hi, Considering the fact that .net is a massive collection of classes, structs, interfaces, methods etc what would be the correct and appropriate approach to get started with and understand the fundamentals of the framework. Bearing in mind the two facts that there is no substitute for experience and that there is no limit to learning...

.NET 3.5SP1 ORM - database agnostic

Hi to all, we're working on an application that digs data from an Oracle DB and a SQLServer one. In need for a (possibly free) ORM solution, I'd like to use Entity Framework, but it does not support Oracle. Any suggestion? Thanks ...

MultiThreading and Deadlock

In which situations we can do the multithreading and deadlock concepts. can give some examples ...

Examples of usage of Generics in .Net (C#/VB.Net)

What are some examples of you would use generics in C#/VB.Net and why would you want to use generics? ...

How do you programmatically (re)sign a .NET assembly with a strong name?

Aside from invoking the command line to add a strong name to an assembly, is there any APIs out there that let you resign an assembly once it has been stripped of its strong name? ...

C#: Declare preprocesor symbol (like DEBUG) globaly for whole project.

Hi, I would like to switch between NUnit and VS Tests like this: #if !NUNIT using Microsoft.VisualStudio.TestTools.UnitTesting; #else using NUnit.Framework; using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using Test...

Webbrowser Control stealing shortcuts

Webbrowser Control in my .NET Windows Form application is stealing shortcuts when on focused. To able to use Alt + F4 I had to click a control first. Currently "WebbrowserShortcuts = false" but it's still same. Is there a way to stop this irritating behaviour? ...