background preloader

C# and ASP

Facebook Twitter

How to get Hidden Column Value in GridView. Suppose I want to display Address details in GridView but don't want to display AddressId then I will hide column that displays AddressId.

How to get Hidden Column Value in GridView

GridView has CheckBox also to select Addresses. Now at runtime on click of button I want to get AddressId of all selected Addresses in that case if I use gvAddress.Rows[index].Cell[1] to get AddressId it will return Nothing. The reason behind is, if Gridview has any BoundField column for which visible property is set to "false" then that columns is not rendered at runtime in GridView and data of hidden column won’t be available . But, there are four other ways to get value of hidden column. 1. First Way - Use DataKeyNames Property of GridView (a).

<! (b). 2. (b). 3. (a). (b). (c). Protected void btnSelect_Click(object sender, EventArgs e) { List<int> lstAddressId = new List<int>(); Control chkSelect = null; for (int iRow = 0; iRow &lt; gvAddress.Rows.Count; iRow++) { chkSelect = gvAddress.Rows[iRow].Cells[0].FindControl("chkSelect"); if (chkSelect !

Logging with Log4Net in C Sharp - EyeCatch. Over the past years I've been asked quite a number of times how to configure Log4Net in C#.

Logging with Log4Net in C Sharp - EyeCatch

There are some examples out there, but I've found that most of are either too complicated or are too specific. In the end I decided that the only way to fix the problem is to write a general tutorial on Log4Net configuration myself. Basics Use NuGet to download and install the latest version of Log4Net. Config files Now you need to configure Log4Net. Before you use an IoC tool, some concepts to know first. JEREMY’s NOTE: I’m trying to rewrite the StructureMap documentation today, and I’m going to blog most of it out here as I finish it until Brendan tells me to stop polluting the main feed.

Before you use an IoC tool, some concepts to know first

This article is intended to be an introduction to the concepts behind an IoC tool for folks with little or no previous exposure. Feedback will be very much appreciated. From my original release back in June 2004: StructureMap is a Inversion of Control (IoC) slash Dependency Injection framework that can be used to improve the architectural qualities of an object oriented system by reducing the mechanical costs of good design techniques. Using StructureMap does not in any way improve your architecture per se, it simply strives to make the mechanics of a good Object Oriented Design cheaper to implement. Over the years a series of concepts and principles have been discovered and developed to describe well-structured Object Oriented systems. Dependencies public class AddressEditController : Controller. WCF response with duplicated elements. Hi Steven, Thanks for clarifying that.

WCF response with duplicated elements

So what you are, in effect, saying is that it is not possible to directly generate the C# code that will return the expected SOAP data from the given XSD definitions and that whenever we are provided with updated XSDs we will have to manually modify the C# code emitted by svcutil (or create them manually)? This appears to be a somewhat, shall we say, suboptimal situation. I had assumed that the whole point of SOAP XSDs and WCF was that it was possible to take definitions generated by (in this case) a Java tool and produce code to generate compliant SOAP messages in .NET.

Where, in your opinion, does the problem lie? Are the XSD's incorrect? Dependency Injection Demystified. When I first heard about dependency injection, I thought, "Dependendiwhatsit?

Dependency Injection Demystified

" and promptly forgot about it. When I finally took the time to figure out what people were talking about, I laughed. "That's all it is? " "Dependency Injection" is a 25-dollar term for a 5-cent concept. That's not to say that it's a bad term... and it's a good tool. The Really Short Version Dependency injection means giving an object its instance variables. The Slightly Longer Version, Part I: Dependency Non-Injection Classes have these things they call methods on.

Public class Example { private DatabaseThingie myDatabase; public Example() { myDatabase = new DatabaseThingie(); } public void DoStuff() { ... Here, we have a variable... uh, dependency... named "myDatabase. " C# Coding Standards and Naming Conventions. Foreach Loop Examples. Foreach is a loop construct.

Foreach Loop Examples

It does not use an integer index. Instead, it is used on a collection and returns each element in order. This is called enumeration. It eliminates errors caused by incorrect index handling. Example We first use the keyword foreach on a string array to loop through the elements in the array. String Array Note:This results in fewer characters to type and code that it is easier to review and verify, with no functionality loss. Program that uses foreach over array: C# using System; class Program { static void Main() { // Use a string array to loop over. string[] ferns = { "Psilotopsida", "Equisetopsida", "Marattiopsida", "Polypodiopsida" }; // Loop with the foreach keyword. foreach (string value in ferns) { Console.WriteLine(value); } } } Output Psilotopsida Equisetopsida Marattiopsida Polypodiopsida We see that the foreach-statement contains the reserved "foreach" keyword.

N-tier

Open XML. MVC3. Linq.