.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Check for empty array?

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :ASP.Net

How do i check for empty array?


If I write

If Not ls_filename.Length = 0 then


End If


I get object refernce set to null error

View Complete Post

More Related Resource Links

How to check for null/empty strings on dynamic objects?


What is the proper way to check for null or empty strings on dynamic objects? This is the only solution I've found so far:

if (admin.PasswordHash.GetType() == typeof(DBNull) || admin.PasswordHash == string.Empty)

If the field is null, the object returned is DBNull.Value, but if the field is empty string, it's return as a System.String object. This makes it impossible to do regular "admin.PasswordHash == DBNull.Value" check, as that will fail whenever the field has been set to empty string. Is my example the right (and only) way to go?

how to check if a Dataview is empty?

I am having trouble with the syntax to check if my Dataview is empty.  If it is empty then the next line when I try draw information from it generates an error. How can I fix this?Dim ProjectDV As DataViewDim arg As New DataSourceSelectArgumentsProjectDV = SqlDataSource1.Select(arg)   If ProjectDV.Count <> 0 ThenpicAd.Text = LCase(ProjectDV(0)("Ad"))End If  

Invalid length for a Base-64 char array - how do I check the length?????


Invalid length for a Base-64 char array

I am encrypting and decrypting my querystring. I need a way of checking the querystrings length before I decrypt it. When I mess with the querystring, shorten it for example, my decryption method fails. Can somebody help me with the if statement please to check the length of the urlDecode string??????

public static string Decrypt(string inputText)      {          if (!String.IsNullOrEmpty(inputText))

How to check if DataTable row is empty



Im using "string user = Database.GetMostRecentReply(id).Rows[0][2].ToString();" to get the username from the most recent reply in my forum.

But how do I check if the row is empty? Im using a try catch at the moment, but there must be a better way to do this.


When to check if something Is Nothing? How do you check an empty textbox?


I currently do something like...

If TextBox1.Text Is Nothing OR Trim(TextBox1.Text) = "" Then

' Do whatever

End If

Now I know this works.. but what is the right way to have this? I don't want to be checking something twice instead of just having it written out once.

how to check duplicate records in array c#



how to check duplicate records in array c#.

In my array list contain string[] arraylist = new Array[] { "First","Second","Third","First" };

what I want is return True or false ? (True = No duplicate, False= Duplicate entry)



Check if item exists in array



I have a javascript function, in which i have declared an array variable.

var strUsers = new Array("John","Mac","George"); 

The above declaration is for sample and the number of items vary.

How to check, if the particular loggedin user for example: Mac is available in the arraylist.

Thank you


Check Empty WebPart Using JQuery


Hi All,

Is it possible to identify a empty webpart in the page?

For e.g, we have an annoucement webPart that has no item, The webpart will display an default OOB Message.

Our Requriement is to identify those empty webpart and hide them. Whether this is possible using JQuery/ Javascript?

Note: Solution should in either in JQuery or Javascript or any those OOB option. We should not do any Coding?

Please let me know whether this is possible?


Ganesh Moorthy S

Check if all members of MeasureGroupMeasures are empty

Is there a way to check if all members of MeasureGroupMeasures are empty in the MDX query?

Javier Guillen

Check Whether the grid view is empty or not



Hello all Members,

I am new to asp.net.

i don't know where to post this issue.

Problem that i am facing is,

I have a grid view bind with LINQdatasource control & i want to check whether it is empty or not.

How do i do this ?

and also, If it is empty, then i have to enable a button control on my form.

Please help me in this issue.

Thanks in advance.


Using trim to check element is empty in jQuery

Using trim method, one can also check element is empty or not.

Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

Check All with JQuery and a Asp.Net GridView

Display a Grid on the screen with a checkbox in each row. At the bottom of the page have "Check All" button.

Typically if I need to do anything interesting I use a template column. So my GridView will look like the one below (most other columns removed for readability). The only interesting point to note is the CssClass="ApprovalCheckBox" in the CheckBox ItemTemplate.

Binding an array to dropdown list


I have the following string which is a list of urls. How do I get this to work so the url shows for the selection and also is the value?      


allLinks = newAllLinks
        Me.DropDownList1.DataTextField = "Link"
        Me.DropDownList1.DataValueField = "LinkURL"
        Me.DropDownList1.Items.Insert(0, New ListItem(" - Select - ", 0))
        Me.DropDownList1.DataSource = allLinks


 ArgumentNullException: Value cannot be null.
Parameter name: container]
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +121
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) +8

check box control


Hi ,

I have a three check box in my web form ,i need to choose only one check box, if i choose one check box

another 2 check box automatically unchecked

can i use jquery for check box

I thought this would be simple... Trying to create a login does an ajax check before submit


I have the standard .net login control that is working.  (Still learning .net after 15yrs of classic)

What I want to do is OnButtonClick run a javascript function (to do an ajax call to the db to check if login is valid or not) and if it returns true, then submit the form normally, else don't submit. The piece that I can't figure out, is how to correctly override the default click even to hit my JS routine and then submit the form properly afterwards.

Thanks ahead of time

how to get an array of all the asp.net textbox control inside create user wizard control?



How can I get all the textboxes inside a create user wizard control using getElementsByTagName().

Below is my JQuery code:

<script type="text/javascript">
        function addLoadEvent(func) {
            var oldonload = window.onload;
            if (typeof window.onload != 'function') {
                window.onload = func;
            } else {
                window.onload = function() {

        function prepareInputsForHints() {
            var inputs = document.getElementsByTagName("asp:TextBox");
            for (var i = 0; i < inputs.length; i++) {
                inputs[i].onfocus = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
                inputs[i].onblur = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "none";



<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend