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

Top 5 Contributors of the Month
Post New Web Links

Array initalization and decleration

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :ASP.Net
Hi,     I have an array of elements..  view plaincopy to clipboardprint? 1. Dim serviceLines() As ServiceLineReq 2. 3. serviceLines = New ServiceLineReq(gvProcedure.Rows.Count - 1) {} 4. Dim i As Integer = 0 5. For Each row As GridViewRow In gvProcedure.Rows 6. 7. serviceLines(i) = New ServiceLineReq() 8. serviceLines(i).ServiceStartDate = DateTime.Today.AddDays(-1).Date 9. 10. serviceLines(i).ProcedureCode = (CType(row.Cells(3).Controls(1), Label)).Text 11. 12. serviceLines(i).DiagnosisCode1 = (CType(row.Cells(8).Controls(1), Label)).Text 13. Dim units As Double = (CType(row.Cells(5).Controls(1), Label)).Text 14. serviceLines(i).Units = CDbl(units) 15. serviceLines(i).UnitsSpecified = True 16. serviceLines(i).UnitCharge = (CType(row.Cells(6).Controls(1), Label)).Text 17. serviceLines(i).UnitChargeSpecified = True 18. 19. newEncounterObj.Practice = practice 20. newEncounterObj.ServiceLocation = locationObj 21. newEncounterObj.Patient = patientObj 22. newEncounterObj.Case = encounterCaseObj 23. newEncounterObj.RenderingProvider = providerObj 24. newEnc

View Complete Post

More Related Resource Links

Array initalization and decleration

Hi,    I have an array of elements..Dim serviceLines() As ServiceLineReq serviceLines = New ServiceLineReq(gvProcedure.Rows.Count - 1) {} Dim i As Integer = 0 For Each row As GridViewRow In gvProcedure.Rows serviceLines(i) = New ServiceLineReq() serviceLines(i).ServiceStartDate = DateTime.Today.AddDays(-1).Date serviceLines(i).ProcedureCode = (CType(row.Cells(3).Controls(1), Label)).Text serviceLines(i).DiagnosisCode1 = (CType(row.Cells(8).Controls(1), Label)).Text Dim units As Double = (CType(row.Cells(5).Controls(1), Label)).Text serviceLines(i).Units = CDbl(units) serviceLines(i).UnitsSpecified = True serviceLines(i).UnitCharge = (CType(row.Cells(6).Controls(1), Label)).Text serviceLines(i).UnitChargeSpecified = True newEncounterObj.Practice = practice newEncounterObj.ServiceLocation = locationObj newEncounterObj.Patient = patientObj newEncounterObj.Case = encounterCaseObj newEncounterObj.RenderingProvider = providerObj newEncounterObj.ServiceStartDateSpecified = True newEncounterObj.ServiceStartDate = DateTime.Today.AddDays(-1).Date i = i + 1 Next now i have to pass these serviceline array to  create methodnewEnc

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

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>

How to cast integer values as an array of enum values?


Hello all!

I'm working with VS2010 Beta2, ASP.NET and Dynamic Data. I'm using VB but will certainly be happy to receive a C# example if necessary. Laughing

I used a few of Steve's examples (Writing Attributes and Extension Methods for Dynamic Data and Dynamic Data - Hiding Columns in selected PageTemplates) to create a custom property attribute to be applied to a dynamic data column and want it to accept an array of enum values (each value will represent a dynamic data page template where this column should not be displayed).  My new attribute works fine when I hardcode it like this, meaning the HideColumnIn attribute is properly populated with the array of enum values:

<HideColumnIn(PageTemplate.List, PageTemplate.Edit)> _
Public Property My_DD_Column As Object


However, I want to store the values to be used for the HideColumnIn in the DB as integer values that correspond to the

Unity - Inject array



I have the following in the config file...

container.RegisterType<ProductInstanceValidatorBase, CartItemStockValidator>();
container.RegisterType<ProductInstanceValidatorBase, MonthlyCartItemValidator>();

..constructor like so...

 public CartValidator(ProductInstanceValidatorBase[] validators)
   this.validators = validators;

...I call the following but the array is empty...


Any ideas?

Cheers, WT.



Converting ReportDocument object into byte array ?


Hi All,

          Is it possible to convert the Report Document object as a byte array and store it in SQL , later retrieve and assing it to a report ?


Invalid length for a Base-64 char array for my coding in ASP.net C#. How to solve it ?


Hi Friends ,

I have done encrypted password and decode but i got error  like  this  " Invalid length for a Base-64 char array" .

Pls help . Thanks


psswd = txtPassword.Text;

pwed = base64Decode(psswd);

public string base64Decode(string sData)
            System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
            System.Text.Decoder utf8Decode = encoder.GetDecoder();
            byte[] todecode_byte = Convert.FromBase64String(sData);
            int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
            char[] decoded_char = new char[charCount];
            utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
            string result = new String(decoded_char); return result;

Class which contains an array of objects of type "Class2"



1  Partial Class _Default
2  Inherits System.Web.UI.Page

3 Public Function Ohjoy(ByVal X As Integer) As Integer
4 Dim theClass As New Class1 '= New Class1()
5    theClass.ReSize(0)
6    theClass.myBaby(0).GetName(0) = "Hello" 'Property Chars is read only'
7    Return 1
8 End Function
I have a first class named "Class1". I have a second class named "Class2" Class2, is a member of class 1,
and is implemented as an array of objects of type Class 2.

If I try and call the Accessor GetName() my hard coded value "Hello" in my accessor is not returned? Only
an alpha character like "T"

Also if I try and assigne a value using the setter GetName() it does not work, and the compiler gives me
an error message "property Chars is ReadOnly? Does anyone know what is wrong in my code? Line 6 above


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class

Public Class Class1
    Dim bs As Integer
    Public myBaby() As Class2
    Public myB As Class2
    Public Function ReSize(By

Query an arraylist of array list using linq


I have an array list called Customer. I t holds a list of array list which has the account details.

proj.customer -> collection of arraylist of type customer

proj.customer.account -> collection of arraylist of type account

Account array list holds type account and it has a poperty account balance. How can I query all accounts which has account balance  >100

I tried the following one

var Accountlist= from Account accountdetails in proj.customer.account

where accountid.balance >100

select accountdetails.id

But it is always throwing an error saying cannot cast type customer to type account

Please help

Basic Instincts: Collection and Array Initializers In Visual Basic 2010


Collection Initializers are a great addition to the language and allows concise syntax in order to initialize both framework and user defined collection types.

Spotty Bowles

MSDN Magazine October 2009

Array List with unique id while adding student info

Hello Frds,

I'm having arraylist to add student info but i have to create unique id per record below is my class.

Student objStudent=new Student(123,"Nj");

public class Student
  private string name;
private int RollId;
public string Name

    get { return name; }
set { name = value; }

public int Id
    get { return RollId; }
set { RollId = value; }
public Employee(string name, int id)


Converting a byte array to a gif


Hi there,

I am currently in the process of trying to convert a byte array into a gif format. So far I have done this:

                        byte[] gif = Convert.FromBase64String(myByteArray);
                        MemoryStream ms = new MemoryStream(gif);
                        Bitmap image = new Bitmap(ms);
                        string pathToSave = Server.MapPath("~/_temp/");
                        iconUrl = string.Format("{0}/{1}.gif", pathToSave, fileName);

When this code block executes, I get the following error:

A generic error occurred in GDI+.

I have made sure that I have the correct permissions for the _temp folder, but I am not sure if I am trying to convert "bad bytes". Could someone perhaps shed some light on this error? 

Conversion of Byte Array to Memory stream


how to convert byte array to memory stream in vb.net.

Sort in array


  I have a collection Role[], in that i want to Sort Order by MerchantID, then RoleName ascending order, how its possible?

Creating an Array of Rectangles

I am trying to create an Array of Rectangles but can't quite get there as the syntax for the last line eludes me. Is there a way to do this  please?   Public aSquare(10) As Rectangle ---------------------- Dim noOfSquares(9) As Integer Dim strname(9) As String Dim ii As Integer For ii = 0 To 9 Strname(ii) = "mySquare" & noOfSquares(ii) Dim theName As String theName = strname(ii) 'Dim aSquare( ?? ) As New Rectangle Next
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