getting the x.name from aspx script


Hi,
I'm trying to add what would be x.name in asp to my aspx script.  Where it says:
myXML.AppendFormat("<a{0} id ='3'
i would rather the id= the equivelent of x.name in asp.

I dont know how the
                 myXML.AppendFormat("<a{0} id ='3'>{1}</a{2}>", i + 1, rdr.GetValue(i).ToString(), i + 1)
line works. I understand Append is to add. I dont know where aspx gets the values for {0} {1} or {2}.
But then thats a different question.

Thanks for your time.
<%@ Page Language="VB" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        
        Response.ContentType = "text/xml"
        Dim frm1 As String = "arr"  'Request.Form("form1")
        Dim SQL As String
        Dim path As String
           
        
        Dim myXML As StringBuilder = New StringBuilder()
        Dim XMLcarrier As String
        Dim CacheRefresh As String = ""
                
        
        Select Case frm1
            
            Case "arr"
               
                SQL = "SELECT * FROM BackOffice_Mo_Crosstab_cnt"
                path = "App_Data/LOSA.mdb"
                
                            
                           
            Case "exe"
                
            Case Else
            
                
        End Select
        
                                  
        
        'If CacheRefresh = "y" Then
            
        Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath(path))
        Dim cmd As New OleDbCommand(SQL, cn)
                   
        cn.Open()
        Dim rdr As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)

        
        myXML.Append("<?xml version='1.0' encoding='ISO-8859-1'?>")
        myXML.Append("<aroot id = '" & Now & "'>")

        While rdr.Read()

            myXML.Append("<r>")
            For i As Integer = 0 To rdr.FieldCount - 1
               
                 myXML.AppendFormat("<a{0} id ='3'>{1}</a{2}>", i + 1, rdr.GetValue(i).ToString(), i + 1)
            
            Next
            myXML.Append("</r>")

        End While
        rdr.Close()

        myXML.Append("</aroot>")
        XMLcarrier = myXML.ToString()
            
        'End If
                
        
        Response.Write(XMLcarrier)
        
    
       
        
        
        
    End Sub

</script>

Open in new window

Baz487Asked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
>myXML.AppendFormat("<a{0} id ='3'>{1}</a{2}>", i + 1, rdr.GetValue(i).ToString(), i + 1)

This is string formatting. The {0} is replaced with "i+1". The {1} is replaced with "rdr.GetValue(i).ToString()" and {2} is again replaced with "i+1".

>i would rather the id= the equivelent of x.name in asp.
Do you want to put one of the SQL values there? Try

myXML.AppendFormat("<a{0} id ='{3}'>{1}</a{2}>", i + 1, rdr.GetValue(i).ToString(), i + 1, rdr.Item("columnname"))
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.