Latest developer linksBookmark and Share
 
HomeThis WeekTop MonthTop AlltimeSearchRegisterFAQ
  
 
Submit Your Link
Please login to submit your Link
 

Using VB, how do I use the For i = 1 to 10 to create a dynamic double variable

Posted: Dec/14/2010   By: nikhil   Points:15   Category: .NET  - ASP.Net    Views:102   Vote Up (0)   Vote Down (0)    

I have some global variables declared and want to access them in subrorutines using the For statement. 

For example, I want to use the following to place values in the global variables , i.e, dblcell1, dblcell2, dblcell3, etc. 

Dim m As Integer
			For m = 3 To 11
				If e.Row.Cells(m).Text <> " " Then
					dblCell & m = e.row.cells(m).text)
				End If
			Next

I know that I can't use the "dblCell & M".  It is just to show the objective. It is where I get an error.

 

Thanks
 

 

View Complete Post


Comments:
Be the first to comment this post.
 
Post Comment
Please login to post your comment
More Related Resources

Dynamic Binding in a Static Language, Part 1

  
This article is taken from the book C# in Depth, Second Edition. This segment looks at what it means for code to be dynamic, and the syntax involved in using dynamic typing in C# 4

Create Navigation in asp.net web application

  
Create Navigation in asp.net web application. Create Navigation in asp.net

How to display dynamic XML data inside a Panel control?

  

Hi all,

I have a SQL routine which builds me an entire XML file and returns it as a string. 
If I save the content of this file as sample.xml for instance, I am able to open it in IE or any other browser and the user can expand the nodes and see all the content he wishes.

I am trying to build a ASP.Net page which will display the content of a XML file in the same way (or similar) that the browsers do.

So far, I've been reading some posts and noticed I can use XmlDataSource control and its Data property to load the entire XML doc as a string. Now I am stuck how to display the contents. I found TreeView very confusing and not sure if DataGrid would be a alternative as well. I need to user to be able to open and expand the nodes.

Please someone point me to the right direction. What controls to use, etc... sample codes are the best ;-)

Thank you

 


create a method similar to this

  

In one of our pages we are using this bit of code to check if something is null and passing in a 0 instead. This works great for this page, but this was done by another person and thye are no longer here.. so i'd like to take that idea and create something similar but return a empty string or blank space, the reason is that i have a page where you make a selection from a gridview and onselect that rows data is passed into some textboxes.. well at the moment, if you select a row and one of the columns is blank, the textbox is being populated anyway with this &nbsp; so i would like to make sure that if there is nothing, that the textboxes are left blank.. since there is potential for having alot of textboxes, i would rather create a method that can do the checking instead of doing if condition for each parameter. does that make sense? If so any suggestions would be great. and thanks you

        //CONVERTS NULL VALUES TO ZERO
        protected string valid(OleDbDataReader myreader, int stval)
        {
            object val = myreader[stval];
            if (val != DBNull.Value)
                return val.ToString();
            else
                return Convert.ToString(0);
        }
        //END


 


Create more than 1 set of controls in runtime.

  

I've figured out how to create the controls in the format I want, but now I am confused as to how create more than one set of them. I set everything to new and increment the names of each control, but it's only updating the one set. Here is my code:

  intPnlCounter += CInt(ViewState("intPgCount"))
        
        'Table
        'PlaceHolder1.Controls.Add(New LiteralControl(" <table style=""height: 27px""><tr><td colspan=""2""> </td><td colspan=""2"">"))
        PlaceHolder1.Controls.Add(New LiteralControl("<table style=""height: 27px"">"))

        'Component Header
        Dim lblHeader As Label = New Label
        lblHeader.Text = "Additional Component Item: " & intPnlCounter
        lblHeader.ID = "lblHeader" & intPnlCounter
        lblHeader.Font.Bold = True
        lblHeader.Font.Underline = True
        lblHeader.Font.Name = "Trebuchet MS"
        PlaceHolder1.Controls.Add(lblHeader)
        PlaceHolder1.Controls.Add(New LiteralControl("<tr><td colspan=""2""> </td><td colspan=""2"">"))

        'Item Label
        Dim lblItem As Label = New Label
        lblItem.Text = "Item:"
        lblItem.ID = "lblItem" & intPnlCounter
        lblItem.Font.Bold = True
        lblItem.Font.Underline = True
        lblItem.Font.Name = "Trebuchet MS"
        'lblItem.Font.Size = Unit.Percentage(10)
        PlaceHolder1.Controls.Add(lblItem)
        PlaceHolder1.Controls.Add(New LiteralControl(" "))
        'Item Textbox
        Dim txtItem As TextBox = New TextBox
        txtItem.ID = "txtItem" & intPnlCounter
        txtItem.Width = Unit.Pixel(306)
        PlaceHolder1.Controls.Add(txtItem)
        PlaceHolder1.Controls.Add(New LiteralControl("</td><td> </td></tr><tr><td class=""style11"">"))

        'NSN Label
        Dim lblNSN As Label = New Label
        lblNSN.Text = "NSN:"
        lblNSN.ID = "lblNSN" & intPnlCounter
        lblNSN.Font.Bold = True
        lblNSN.Font.Underline = True
        lblNSN.Font.Name = "Trebuchet MS"
        lblNSN.Font.Size = 10
        PlaceHolder1.Controls.Add(lblNSN)
        PlaceHolder1.Controls.Add(New LiteralControl(" "))
        'NSN Textbox
        Dim txtNSN As TextBox = New TextBox
        txtNSN.ID = "txtNSN" & intPnlCounter
        PlaceHolder1.Controls.Add(txtNSN)
        PlaceHolder1.Controls.Add(New LiteralControl("</td><td class=""style12"">"))

        'PartNum Label
        Dim lblPartNum As Label = New Label
        lblPartNum.Text = "Part Number:"
        lblPartNum.ID = "lblPartNum" & intPnlCounter
        lblPartNum.Font.Bold = True
        lblPartNum.Font.Underline = True
        lblPartNum.Font.Name = "Trebuchet MS"
        lblPartNum.Font.Size = 10
        PlaceHolder1.Controls.Add(lblPartNum)
        PlaceHolder1.Controls.Add(New LiteralControl(" "))
        'PartNum Textbox
        Dim txtPartNum As TextBox = New TextBox
        txtPartNum.ID = "txtPartNum" & intPnlCounter
        PlaceHolder1.Controls.Add(txtPartNum)
        PlaceHolder1.Controls.Add(New LiteralControl("</td><td colspan=""2"">"))

        'SerialNum Label
        Dim lblSerialNum As Label = New Label
        lblSerialNum.Text = "Serial Number:"
        lblSerialNum.ID = "lblSerialNum" & intPnlCounter
        lblSerialNum.Font.Bold = True
        lblSerialNum.Font.Underline = True
        lblSerialNum.Font.Name = "Trebuchet MS"
        lblSerialNum.Font.Size = 10
        PlaceHolder1.Controls.Add(lblSerialNum)
        PlaceHolder1.Controls.Add(New LiteralControl(" "))
        'SerialNum Textbox
        Dim txtSerialNum As TextBox = New TextBox
        txtSerialNum.ID = "txtSerialNum" & intPnlCounter
        PlaceHolder1.Controls.Add(txtSerialNum)
        PlaceHolder1.Controls.Add(New LiteralControl("</td><td>"))

        'Hours Label
        Dim lblHours As Label = New Label
        lblHours.Text = "Hours:"
        lblHours.ID = "lblHours" & intPnlCounter
        lblHours.Font.Bold = True
        lblHours.Font.Underline = True
        lblHours.Font.Name = "Trebuchet MS"
        lblHours.Font.Size = 10
        PlaceHolder1.Controls.Add(lblHours)
        PlaceHolder1.Controls.Add(New LiteralControl(" "))
        'Hours Textbox
        Dim txtHours  

How can i create Barcode for coupon???

  

 Hi all,

I am creating a web site that provide coupon for it's registered member. I want to set up barcoad for each coupon that the member printed. How can i create barcode and Print them in a html page that is used as my coupon page.

Is anybody can give me solution for that???? Please help me, its argent.

Bye

With regards

Sadequzzaman Monoj

Bangladesh


Need help: Issue with Dynamic Checkboxes CheckChanged Events

  

Hello All, I have almost broken my head on this whole day today, looks like i am not getting something and thats why its not working. Someone please help.

Below is the scenario:
In the aspx page, i am dynamically adding a checkbox to an htmltable.  To its CheckChanged event, i am adding one more row in the table and adding another checkbox. I am not able to get this new checkbox's CheckChanged event. I understand that its not getting created, but i am not sure how do i handle it.
Below is the code, can someone help me correct this code and help me on how do i achieve it.

Note: I have to use the HtmlTable.Rows.Insert method only, to add the new row with its controls to the HtmlTable based on indexes.

ASPX PAGE

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>        
        <table id="tblGenerator" runat="server"></table>
    </div>
    </form>
</body>
</html>
ASPX.CS PAGE - CODE BEHIND

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            tblGenerator.Style.Add("border", "1");
            tblGenerator.EnableViewState = true;
            HtmlTableRow tblRow = new HtmlTableRow();

            HtmlTableCell tblCellLeft = new HtmlTableCell();
            HtmlTableCell tblCellRight = new HtmlTableCell();

            Label lblOne = new Label();
            lblOne.ID = "lblOne_1";
            lblOne.Text = "This is for checkbox 1";
            tblCellLeft.Controls.Add(lblOne);

            CheckBox chkBoxOne = new CheckBox();
            chkBoxOne.ID = "chkOne_1";
            chkBoxOne.AutoPostBack = true;
            chkBoxOne.EnableViewState = true;
            chkBoxOne.CheckedChanged +=new EventHandler(chkBoxOne_CheckedChanged);
            tblCellRight.Controls.Add(chkBoxOne);

            tblRow.Cells.Add(tblCellLeft);
            tblRow.Cells.Add(tblCellRight);

            tblGenerator.Rows.Add(tblRow);            
        }

        void  chkBoxOne_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox chkBox = (CheckBox)sender;

            HtmlTableRow parentRow = (HtmlTableRow)chkBox.Parent.Parent;
            HtmlTable parentTable = (HtmlTable)chkBox.Parent.Parent.Parent;

            int index = parentTable.Controls.IndexOf(parentRow);

            HtmlTableRow newRow = new HtmlTableRow();
            HtmlTableCell childTblCellLeft = new HtmlTableCell();
            HtmlTableCell childTblCellRight = new HtmlTableCell();

            Label childLblOne = new Label();
            childLblOne.ID = "childLblOne_1";
            childLblOne.Text = "This is for child checkbox";
            childTblCellLeft.Controls.Add(childLblOne);

            CheckBox childChkBoxOne = new CheckBox();
            childChkBoxOne.ID = "childChkOne_1";
            childChkBoxOne.AutoPostBack = true;
            childChkBoxOne.EnableViewState = true;
            childChkBoxOne.CheckedChanged += new EventHandler(childChkBoxOne_CheckedChanged);
            childTblCellRight.Controls.Add(childChkBoxOne);

            newRow.Cells.Add(childTblCellLeft);
            newRow.Cells.Add(childTblCellRight);

            //add 1 to the parent table's row index to insert new row to the parent table ...            
            parentTable.Rows.Insert(index + 1, newRow);            
        }

        void childChkBoxOne_CheckedChanged(object sender, EventArgs e)
        {
            Response.Write("Child checkbox changed");
        }
    }
}



 


Dynamic gridview paging

  

Hi, all --

I've already searched to no avail for an answer to this question: is it possible to dynamically alter the page size in a paged gridview based on data in a particular column? In other words, let's say I get data from a table that lists students enrolled in a particular course. If there are 10 students in Course "A," then I want page 1 in my gridview to show 10 records. If there are 15 students in Course "B," then I want page 2 in my gridview to show those 15 records, and so on. I imagine that this could probably be done with a master-detail kind of set up, but let's say for the sake of argument that I don't want to go that route.

Thanks in advance for any suggestions.

Ken



Trying to create a data set that I can reuse

  

Hard to describe be here goes.

Currently I have this in the aspx page

<% = new BuildFormField() { FieldName = "FirstName" }%>

And the simplified object

Class BuildFormField(){

   return GetFieldAttributes("FirstName") //calls a linq query based on the field name to get all the attributes of the field ie size/class and builds the html string.

}

The problem is, I will have many of these and it queries the database every time. What I would like to do is build a general dataset once and query that result set for each field.

I can't figure out where I should setup the initial query. Obviously don't want to put it in the aspx page or the controller and I can't figure out how to create a class that would only get called once that I could use again inside the BuildFormField Class.

Hope that makes sense. Yea, a bit unusual of a way to create form fields, but there is good reasons.

 

Thanks ahead of time.


"Failed to create AppDomain"

  

Hello,

When I click on execution of asp.net application, when loading of page on browser, I get following exception error message:

"Failed to create AppDomain"

despite search results via google on this following steps dealing with renaming of security.config or doing  caspol -reset didn't work:

http://forums.asp.net/t/1304604.aspx

http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2005/03/16/5345.aspx

Is there any other idea how to fix this? I can't help this, I've googled enough.

I previously had Visual Studio 2008 installed. Now I have Visual Studio 2010 besides Visual Web Developer express 2010 installed. Can this be problem? I don't know at all what to do.

Thank for your answers.

Failed to create AppDomain


 
Categories:
.NET
Java
PHP
C/C++/VC++
HTML/XML
SAP
MainFrames
Data Warehousing
Testing
MySQL
SQL Server
Oracle
Javascript/VB Script
Others
Login
 
 
 
 
 Forgot password
 Contact Us   Terms Of use   Share your knowledge