Posts Tagged ‘’

GridView: Findcontrol from HeaderTemplate/ItemTemplate

September 19, 2017 Leave a comment

How to find item template control in GridView?

Dim chkHeader As CheckBox = DirectCast(gridView1.Row.FindControl(“chkHeader”), CheckBox)

How to find control from header template in grid view?

For example If you want to find checkbox available in header template of gridview

<asp:GridView ID=”gridView1″ runat=”server” AutoGenerateColumns=”False”><Columns>

<asp:TemplateField >


<asp:CheckBox ID=”chkHeader” runat=”server” />


</asp:TemplateField >




Find Header control using following line of code

VB.NET Code:

Dim chkHeader As CheckBox = DirectCast(gridView1.HeaderRow.FindControl(“chkHeader”), CheckBox)

C# Code:

CheckBox chkHeader = (CheckBox)gridView1.HeaderRow.FindControl(“chkHeader”);

Hope this is help !







Is it possible to disable forms authentication for specific sub directories of an application?

Yes we can disable forms authentications for specific sub directory using below code in config files

<location path="Folder" allowOverride=”false”>
                <allow users="*" />
 Hope this help !

File Download code in

If Not String.IsNullOrEmpty(strURL) Then
Dim req As New WebClient()
Dim response As HttpResponse = HttpContext.Current.Response
response.Buffer = True
response.AddHeader(“Content-Disposition”, “attachment;filename=””” + Server.MapPath(strURL) + “”””)
Dim data As Byte() = req.DownloadData(Server.MapPath(strURL))
End If


Hope it helps !

SalesForce (Login) Integration With ASP.NET

April 24, 2015 1 comment


  1. Add Service Reference, select Advanced and then select Add Web Reference.
  2. In the URL box of the Add Web Reference dialog box, type the URL to obtain the service description of the XML Web service you want to access, such as:


  3. Click Go to retrieve information about the XML Web service.
  4. In the Web reference name box, rename the Web reference to sforce, which is the name you will use for this Web reference.
  5. Click Add Reference to add a Web reference for the target XML Web service.
  6. Visual Studio retrieves the service description and generates a proxy class to interface between your application and the XML Web service.

Issues :

error CS0030: Cannot convert type ‘SFDC.ListViewRecordColumn[]’ to ‘SFDC.ListViewRecordColumn’
error CS0030: Cannot convert type ‘SFDC.ListViewRecordColumn[]’ to ‘SFDC.ListViewRecordColumn’
error CS0029: Cannot implicitly convert type ‘SFDC.ListViewRecordColumn’ to ‘SFDC.ListViewRecordColumn[]’
error CS0029: Cannot implicitly convert type ‘SFDC.ListViewRecordColumn’ to ‘SFDC.ListViewRecordColumn[]’


Add following to enterprise.wsdl.xml

<xsd:attribute name=”tmp” type=”xsd:string”></xsd:attribute>


<complexType name=”ListViewRecord”>
<element name=”columns” type=”tns:ListViewRecordColumn” maxOccurs=”unbounded”/>
<xsd:attribute name=”tmp” type=”xsd:string”></xsd:attribute>

Hope this help!

Deep and Shallow Copying, Difference of Shallow and Deep Copying

December 16, 2014 Leave a comment

What is Shallow Copy?

Shallow copy is a bit-wise copy of an object. A new object is created that has an exact copy of the values in the original object. If any of the fields of the object are references to other objects, just the reference addresses are copied i.e., only the memory address is copied.

What is Deep Copy?

A deep copy copies all fields, and makes copies of dynamically allocated memory pointed to by the fields. A deep copy occurs when an object is copied along with the objects to which it refers.

When creating copies of arrays or objects one can make a deep copy or a shallow copy. This explanation uses arrays.

Recall array variables in Java are references or pointers. A shallow copy can be made by simply copying the reference.

public class Ex{
private int[] data;

public Ex(int[] values){
data = values;

public void showData(){
System.out.println( Arrays.toString(data) );

The above code shows shallow copying. data simply refers to the same array as vals.


This can lead to unpleasant side effects if the elements of values are changed via some other reference.

public class UsesEx{
public static void main(String[] args){
int[] vals = {-5, 12, 0};
Ex e = new Ex(vals);
e.showData(); // prints out [-5, 12, 0]
vals[0] = 13;
e.showData(); // prints out [13, 12, 0]
// Very confusiin, because I didn’t intentionally change anything about the
// object e refers to.

A deep copy means actually creating a new array and copying over the values.

public class Ex{
private int[] data;

public Ex(int[] values){
data = new int[values.length];
for(int i = 0; i < data.length; i++)
data[i] = values[i];

public void showData(){
System.out.println( Arrays.toString(data) );

The above code shows deep copying.


Changes to the array values refers to will not result in changes to the array data refers to.

How to check if the user enters the default datetime? VB.NET

In VB.NET if we pass nothing to date it will return default value like ” #12:00:00 AM# ‘


To check if date is not default date than following should be used

IfNotDate.MinValue = MyDate


Hope it helps

Categories: VB.NET Tags: , , ,

Proper case in

December 12, 2013 Leave a comment

Convert a String to Uppercase

The String class has a static method named ToUpper. You can use this method to convert a string to uppercase. You can also use the UCase or StrConv function. For example:

    Dim upper as String = "converted from lowercase"

Convert a String to Lowercase

The ToLower method is the complement of the ToUpper method. ToLower converts a string to lowercase. You can also use the LCase or StrConv function. For example:

    Dim lower as String = "CONVERTED FROM UPPERCASE"

Convert a String to Title Case

To convert a string to title (or proper) case, pass the string to the StrConv function with a constant that identifies the operation to be performed. For example:

Dim title as String = "converted to title case"
    Console.WriteLine(StrConv(title, VbStrConv.ProperCase))

Convert String Using the TextInfo Class

This section describes how to use the TextInfo class to convert strings. Because you can use the conversion methods inTextInfo to control culture information, you may want to use this class when you need to specify particular culture settings.

TextInfo is member of the System.Globalization namespace. TextInfo provides the ToUpperToLower, and ToTitleCasemethods for conversion to uppercase, lowercase, and title case respectively. Unlike the methods of the String class, theTextInfo methods are not static methods and require an instance of the class.

In most situations, you can default to the culture that is currently in use. Culture information is a property of the thread on which the code is running. To obtain the culture information, you must gain access to the current thread and retrieve theCurrentCulture property from that thread. Once you accomplish this, you can create the TextInfo object. For example:
    Dim curCulture As CultureInfo = Thread.CurrentThread.CurrentCulture
    Dim tInfo As TextInfo = curCulture.TextInfo()
The following code sample illustrates how to call the three string conversion methods of the TextInfo class:
Dim title as String = "converted using textinfo"
Example :

Imports System.Globalization
Imports System.Threading
Module Module1

    Public Sub main()

        Dim title As String = "this is my converted string"

        Console.WriteLine("Built-in Methods")
        Console.WriteLine(StrConv(title, VbStrConv.UpperCase))
        Console.WriteLine(StrConv(title, VbStrConv.LowerCase))
        Console.WriteLine(StrConv(title, VbStrConv.ProperCase))

        Console.WriteLine("String Class")

        Console.WriteLine("TextInfo Class")
        'Get culture information from current thread.
        Dim curCulture As CultureInfo = Thread.CurrentThread.CurrentCulture
        'Create TextInfo object.
        Dim tInfo As TextInfo = curCulture.TextInfo()
        'Convert to uppercase.
        'Convert to lowercase.
        'Convert to title case.
    End SubEnd Module