No sweat.
I sent an email to DeveloperFusion, suggesting that they
widen the textbox where the code to be converted is inserted.
That would prevent that problem from occurring
( unless the line is humongously long... ).
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ :
http://asp.net.do/faq/
Foros de ASP.NET en Espaņol :
http://asp.net.do/foros/
======================================
"Mr Newbie" <here@now.com> wrote in message
news:%23EjHL70xFHA.2540@TK2MSFTNGP09.phx.gbl...[color=blue]
> Thanks for the follow up on this Juan. I dont think I would have had the energy
>
> ;-)
>
>
>
> "Juan T. Llibre" <nomailreplies@nowhere.com> wrote in message
> news:uZRg8S0xFHA.2212@TK2MSFTNGP15.phx.gbl...[color=green]
>> re:[color=darkred]
>>> Many thanks Juan for this utility for conversion.[/color]
>>
>> You're very welcome.
>>
>> re:[color=darkred]
>>> Mr.Newbie:
>>> your code has errors[/color]
>>
>> Actually, it doesn't.
>>
>> You have to work around the limitations of the conversion tool,
>> by making sure you insert code-line breaks ( the underscore in VB.NET )
>> so that the conversion utility doesn't think the code statements are truncated.
>>
>> So, if you insert underscores at the end of the longest lines,
>> the conversion tool can understand them.
>>
>> For example, here's an appropiately marked source segment :
>>
>> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As _
>> System.EventArgs) Handles MyBase.Load
>> 'Put user code to initialize the page here
>>
>> If Not Page.IsPostBack Then
>>
>> Me.adaptCalls.Fill(Me.DsCalls1)
>> Me.adaptContacts.Fill(Me.DsContacts1)
>> Me.adaptContactTypes.Fill(Me.DsContactTypes1)
>>
>> AddToCache("adaptCalls", adaptCalls)
>> AddToCache("adaptContacts", adaptContacts)
>> AddToCache("adaptContactTypes", adaptContactTypes)
>>
>> AddToCache("dsCalls", DsCalls1)
>> AddToCache("dsContacts", DsContacts1)
>> AddToCache("dsContactTypes", DsContactTypes1)
>>
>> End If
>> End Sub
>>
>> That is correctly converted by the conversion utility to :
>>
>> private void Page_Load(object sender, System.EventArgs e)
>> {
>> if (!(Page.IsPostBack)) {
>> this.adaptCalls.Fill(this.DsCalls1);
>> this.adaptContacts.Fill(this.DsContacts1);
>> this.adaptContactTypes.Fill(this.DsContactTypes1);
>> AddToCache("adaptCalls", adaptCalls);
>> AddToCache("adaptContacts", adaptContacts);
>> AddToCache("adaptContactTypes", adaptContactTypes);
>> AddToCache("dsCalls", DsCalls1);
>> AddToCache("dsContacts", DsContacts1);
>> AddToCache("dsContactTypes", DsContactTypes1);
>> }
>> }
>>
>> btw, the conversion utility may not do a complete conversion,
>> or even a completely accurate one, but it sure saves a lot of
>> typing, since -mostly- checking code for errors is much easier
>> than writing it.
>>
>> I'm sure some will disagree on this... ;-)
>>
>>
>>
>>
>> Juan T. Llibre, ASP.NET MVP
>> ASP.NET FAQ :
http://asp.net.do/faq/
>> Foros de ASP.NET en Espaņol :
http://asp.net.do/foros/
>> ======================================
>> "Bishoy George" <bishoy@bishoy.com> wrote in message
>> news:OMEhoF0xFHA.1032@TK2MSFTNGP12.phx.gbl...[color=darkred]
>>> Many thanks Juan for this utility for conversion.
>>>
>>> Mr.Newbie:
>>> your code has errors so I can't understand it or even convert it. Still, thank you.
>>>
>>>
>>>
>>> "Juan T. Llibre" <nomailreplies@nowhere.com> wrote in message
>>> news:ekOIuCzxFHA.3524@TK2MSFTNGP14.phx.gbl...
>>>> Why don't you use an online conversion utility ?
>>>>
>>>>
http://www.developerfusion.co.uk/uti...btocsharp.aspx
>>>>
>>>> will convert VB.NET to C# ( and C# to VB.NET ) for you.
>>>>
>>>>
>>>>
>>>> Juan T. Llibre, ASP.NET MVP
>>>> ASP.NET FAQ :
http://asp.net.do/faq/
>>>> Foros de ASP.NET en Espaņol :
http://asp.net.do/foros/
>>>> ======================================
>>>> "Bishoy George" <bishoy@bishoy.com> wrote in message
>>>> news:eRdB1TyxFHA.3300@TK2MSFTNGP09.phx.gbl...
>>>>>I am very disturbing, but if you please could you write it again in C# because I
>>>>>don't
>>>>>understand vb.net.
>>>>> Many Thanks.
>>>>
>>>>> "Mr Newbie" <here@now.com> wrote in message
>>>>> news:eH0K3PyxFHA.3180@TK2MSFTNGP14.phx.gbl...
>>>>>> Here's a little example which uses a helper function. And yes your right about the
>>>>>> constructor but that was not meant to be tested code just really to point you in
>>>>>> the
>>>>>> right direction. In this example, the form is simply a main switchboard which does
>>>>>> not use any data, on the other forms in the application they define the dataset,
>>>>>> and
>>>>>> adapter as class level variables and load them from cache in the Page_Load event as
>>>>>> described which can be done with a simple assignment
>>>>>> variableName=cache("storedIdentifier").
>>>>>>
>>>>>> Hope this helps you.
>>>>>>
>>>>>> Regards - Mr N. . . .
>>>>>>
>>>>>> ----------------------
>>>>>>
>>>>>> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>>>>>> System.EventArgs)
>>>>>> Handles MyBase.Load
>>>>>> 'Put user code to initialize the page here
>>>>>>
>>>>>> If Not Page.IsPostBack Then
>>>>>>
>>>>>> Me.adaptCalls.Fill(Me.DsCalls1)
>>>>>> Me.adaptContacts.Fill(Me.DsContacts1)
>>>>>> Me.adaptContactTypes.Fill(Me.DsContactTypes1)
>>>>>>
>>>>>> AddToCache("adaptCalls", adaptCalls)
>>>>>> AddToCache("adaptContacts", adaptContacts)
>>>>>> AddToCache("adaptContactTypes", adaptContactTypes)
>>>>>>
>>>>>> AddToCache("dsCalls", DsCalls1)
>>>>>> AddToCache("dsContacts", DsContacts1)
>>>>>> AddToCache("dsContactTypes", DsContactTypes1)
>>>>>>
>>>>>>
>>>>>> End If
>>>>>>
>>>>>>
>>>>>> End Sub
>>>>>>
>>>>>> Private Sub AddToCache(ByVal name As String, ByVal item As Object)
>>>>>> If Not IsNothing(Cache(name)) Then
>>>>>> Return
>>>>>> Else
>>>>>> Cache.Add(name, item, Nothing, DateTime.MaxValue,
>>>>>> System.TimeSpan.FromDays(20), Caching.CacheItemPriority.Default, Nothing)
>>>>>> End If
>>>>>> End Sub
>>>>>>
>>>>>>
>>>>>>
>>>>>> "Bishoy George" <bishoy@bishoy.com> wrote in message
>>>>>> news:uls67JyxFHA.2228@TK2MSFTNGP11.phx.gbl...
>>>>>>> You are right. But, please write me more specific coding about caching:
>>>>>>> 1- code of caching exactly: as I looked at msdn there is difficult things to set
>>>>>>> and
>>>>>>> there is no overloading of Cache.Add() that takes 1 parameter as you wrote.
>>>>>>> 2- where exactly to put that caching code?
>>>>>>> Thanks.
>>>>>>>
>>>>>>> "Mr Newbie" <here@now.com> wrote in message
>>>>>>> news:uVpOT8xxFHA.2792@tk2msftngp13.phx.gbl...
>>>>>>>> The problem is that when you click the Dropdown Box, you trigger a postback.
>>>>>>>> Unfortunately, your Page_Load event only fills the dataset during the initial
>>>>>>>> GET.
>>>>>>>> So there is no data to be had when you do your Autopostback.
>>>>>>>>
>>>>>>>> Once a Webform is constructed and the page rendered, the object is destroyed. You
>>>>>>>> need to arrange for the data to be filled on the initial get and saved to the
>>>>>>>> cache
>>>>>>>> for example.
>>>>>>>>
>>>>>>>> cache("ds1)= Ds1
>>>>>>>>
>>>>>>>>
>>>>>>>> and as an else condition to your if not IsPostback
>>>>>>>>
>>>>>>>> ds1 = cache("ds1")
>>>>>>>>
>>>>>>>> page.DataBind() .. . . . .etc
>>>>>>>>
>>>>>>>> PS: This is a common mistake to make.
>>>>>>>>
>>>>>>>> HTH
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> "Bishoy George" <bishoy@bishoy.com> wrote in message
>>>>>>>> news:uNXMQ%23vxFHA.3180@TK2MSFTNGP14.phx.gbl...
>>>>>>>>>I have a dataset called ds1 filled with 2 tables Employees and Customers from
>>>>>>>>>Northwind database.
>>>>>>>>> I have dropdownList called ddLastName with the following properties:
>>>>>>>>>
>>>>>>>>> ddLastName.DataSource = ds1;
>>>>>>>>> ddLastName.DataMember = "Employees";
>>>>>>>>> ddLastName.DataTextField = "LastName";
>>>>>>>>> ddLastName.DataBind();
>>>>>>>>> ddLastName.Items.Insert(0,"Select:");
>>>>>>>>>
>>>>>>>>> I have a label called lblDisplay
>>>>>>>>>
>>>>>>>>> I want the label to display the Notes column data of the selected item in the
>>>>>>>>> dropdownList.
>>>>>>>>>
>>>>>>>>> My code is causing a NullReferenceException.
>>>>>>>>> Can anyone find out what is the problem please?
>>>>>>>>>
>>>>>>>>> ------------------------------------
>>>>>>>>> Code: ----------------------------------------------------
>>>>>>>>> <%@ Page language="c#" Codebehind="WebForm9.aspx.cs" AutoEventWireup="false"
>>>>>>>>> Inherits="WebApplication2.WebForm9" %>
>>>>>>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
>>>>>>>>> <HTML>
>>>>>>>>> <HEAD>
>>>>>>>>> <title>WebForm9</title>
>>>>>>>>> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
>>>>>>>>> <meta content="C#" name="CODE_LANGUAGE">
>>>>>>>>> <meta content="JavaScript" name="vs_defaultClientScript">
>>>>>>>>> <meta content="http://schemas.microsoft.com/intellisense/ie5"
>>>>>>>>> name="vs_targetSchema">
>>>>>>>>> </HEAD>
>>>>>>>>> <body MS_POSITIONING="GridLayout">
>>>>>>>>> <form id="Form1" method="post" runat="server">
>>>>>>>>> <asp:Label id="lblDisplay" style="Z-INDEX: 101; LEFT: 144px; POSITION:
>>>>>>>>> absolute;
>>>>>>>>> TOP: 19px"
>>>>>>>>> runat="server" Width="536px" Height="8px"></asp:Label>
>>>>>>>>> <asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 24px; POSITION:
>>>>>>>>> absolute; TOP: 152px"
>>>>>>>>> runat="server" Width="672px" Height="120px" BorderColor="#3366CC"
>>>>>>>>> BorderStyle="None" BorderWidth="1px"
>>>>>>>>> BackColor="White" CellPadding="4">
>>>>>>>>> <FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>
>>>>>>>>> <SelectedItemStyle Font-Bold="True" ForeColor="#CCFF99"
>>>>>>>>> BackColor="#009999"></SelectedItemStyle>
>>>>>>>>> <ItemStyle ForeColor="#003399" BackColor="White"></ItemStyle>
>>>>>>>>> <HeaderStyle Font-Bold="True" ForeColor="#CCCCFF"
>>>>>>>>> BackColor="#003399"></HeaderStyle>
>>>>>>>>> <PagerStyle HorizontalAlign="Left" ForeColor="#003399" BackColor="#99CCCC"
>>>>>>>>> Mode="NumericPages"></PagerStyle>
>>>>>>>>> </asp:DataGrid>
>>>>>>>>> <asp:DropDownList id="ddLastName" style="Z-INDEX: 103; LEFT: 16px; POSITION:
>>>>>>>>> absolute; TOP: 16px"
>>>>>>>>> runat="server" Width="112px" Height="24px"
>>>>>>>>> AutoPostBack="True"></asp:DropDownList>
>>>>>>>>> <asp:Label id="lblText" style="Z-INDEX: 104; LEFT: 144px; POSITION: absolute;
>>>>>>>>> TOP: 48px" runat="server"
>>>>>>>>> Width="272px" Height="16px" ForeColor="Red">I want to display notes of
>>>>>>>>> selected
>>>>>>>>> employee</asp:Label>
>>>>>>>>> <asp:Label id="lblSpecific" style="Z-INDEX: 105; LEFT: 16px; POSITION:
>>>>>>>>> absolute;
>>>>>>>>> TOP: 72px"
>>>>>>>>> runat="server" Width="704px" Height="56px"></asp:Label></form>
>>>>>>>>> </body>
>>>>>>>>> </HTML>
>>>>>>>>>
>>>>>>>>> --------------------------------------------------code
>>>>>>>>> behind--------------------------------------------------------------------------
>>>>>>>>> using System;
>>>>>>>>> using System.Collections;
>>>>>>>>> using System.ComponentModel;
>>>>>>>>> using System.Data;
>>>>>>>>> using System.Data.SqlClient;
>>>>>>>>> using System.Drawing;
>>>>>>>>> using System.Web;
>>>>>>>>> using System.Web.SessionState;
>>>>>>>>> using System.Web.UI;
>>>>>>>>> using System.Web.UI.WebControls;
>>>>>>>>> using System.Web.UI.HtmlControls;
>>>>>>>>>
>>>>>>>>> namespace WebApplication2
>>>>>>>>> {
>>>>>>>>> /// <summary>
>>>>>>>>> /// Summary description for WebForm9.
>>>>>>>>> /// </summary>
>>>>>>>>> public class WebForm9 : System.Web.UI.Page
>>>>>>>>> {
>>>>>>>>> protected DataSet ds1 = new DataSet();
>>>>>>>>> protected System.Web.UI.WebControls.Label lblDisplay;
>>>>>>>>> protected System.Web.UI.WebControls.DataGrid DataGrid1;
>>>>>>>>> protected System.Web.UI.WebControls.Label lblText;
>>>>>>>>> protected System.Web.UI.WebControls.Label lblSpecific;
>>>>>>>>> protected System.Web.UI.WebControls.DropDownList ddLastName;
>>>>>>>>>
>>>>>>>>> private void Page_Load(object sender, System.EventArgs e)
>>>>>>>>> {
>>>>>>>>> if(!Page.IsPostBack)
>>>>>>>>> {
>>>>>>>>> string connectionString = "data source =localhost; initial catalog
>>>>>>>>> =Northwind;
>>>>>>>>> integrated security=true;";
>>>>>>>>> SqlConnection sqlConnection1 = new SqlConnection(connectionString);
>>>>>>>>>
>>>>>>>>> SqlCommand sqlCommand1 = new SqlCommand();
>>>>>>>>> SqlDataAdapter sda1 = new SqlDataAdapter();
>>>>>>>>>
>>>>>>>>> // "dataset defined at class level"
>>>>>>>>> // DataSet ds1 = new DataSet();
>>>>>>>>>
>>>>>>>>> sda1.SelectCommand = sqlCommand1;
>>>>>>>>> sda1.SelectCommand.Connection = sqlConnection1;
>>>>>>>>> sda1.SelectCommand.CommandType = CommandType.Text;
>>>>>>>>> sda1.SelectCommand.CommandText = "select * from Employees";
>>>>>>>>>
>>>>>>>>> sda1.Fill(ds1,"Employees");
>>>>>>>>>
>>>>>>>>> SqlDataAdapter sda2 = new SqlDataAdapter();
>>>>>>>>>
>>>>>>>>> sda2.SelectCommand = sqlCommand1;
>>>>>>>>> sda2.SelectCommand.Connection = sqlConnection1;
>>>>>>>>> sda2.SelectCommand.CommandType = CommandType.Text;
>>>>>>>>> sda2.SelectCommand.CommandText = "select * from Customers";
>>>>>>>>>
>>>>>>>>> sda2.Fill(ds1,"Customers");
>>>>>>>>>
>>>>>>>>> ddLastName.DataSource = ds1;
>>>>>>>>> ddLastName.DataMember = "Employees";
>>>>>>>>> ddLastName.DataTextField = "LastName";
>>>>>>>>> ddLastName.DataBind();
>>>>>>>>> ddLastName.Items.Insert(0,"Select:");
>>>>>>>>>
>>>>>>>>> // to fill with specific cell data
>>>>>>>>> lblSpecific.Text = "Displaying specific Data:<br><br>";
>>>>>>>>> lblSpecific.Text += ds1.Tables["Employees"].Rows[0]["Notes"].ToString();
>>>>>>>>>
>>>>>>>>> // to fill the datagrid
>>>>>>>>> DataGrid1.DataSource = ds1;
>>>>>>>>> DataGrid1.DataMember = "Employees";
>>>>>>>>> DataGrid1.DataBind();
>>>>>>>>>
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> #region Web Form Designer generated code
>>>>>>>>> override protected void OnInit(EventArgs e)
>>>>>>>>> {
>>>>>>>>> //
>>>>>>>>> // CODEGEN: This call is required by the ASP.NET Web Form Designer.
>>>>>>>>> //
>>>>>>>>> InitializeComponent();
>>>>>>>>> base.OnInit(e);
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> /// <summary>
>>>>>>>>> /// Required method for Designer support - do not modify
>>>>>>>>> /// the contents of this method with the code editor.
>>>>>>>>> /// </summary>
>>>>>>>>> private void InitializeComponent()
>>>>>>>>> {
>>>>>>>>> this.ddLastName.SelectedIndexChanged += new
>>>>>>>>> System.EventHandler(this.ddLastName_SelectedIndexC hanged);
>>>>>>>>> this.Load += new System.EventHandler(this.Page_Load);
>>>>>>>>>
>>>>>>>>> }
>>>>>>>>> #endregion
>>>>>>>>>
>>>>>>>>> private void ddLastName_SelectedIndexChanged(object sender, System.EventArgs e)
>>>>>>>>> {
>>>>>>>>> if(ddLastName.SelectedIndex != 0)
>>>>>>>>> {
>>>>>>>>> int i = 0;
>>>>>>>>> foreach(DataRow r in ds1.Tables["Employees"].Rows)
>>>>>>>>> {
>>>>>>>>> if(r["LastName"].ToString() == ddLastName.SelectedItem.Text)
>>>>>>>>> {
>>>>>>>>> lblDisplay.Text = ds1.Tables["Employees"].Rows[i]["Notes"].ToString();
>>>>>>>>> }
>>>>>>>>> i++;
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>> else
>>>>>>>>> {
>>>>>>>>> lblDisplay.Text = "";
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>[/color]
>>
>>
>>[/color]
>
>[/color]