Click here to Skip to main content
15,912,578 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to Bind Data to EditItemTemplate Control? Pin
_AK_30-May-06 20:33
_AK_30-May-06 20:33 
Questionerror in oledb connection string Pin
thomas_joyee30-May-06 18:48
thomas_joyee30-May-06 18:48 
AnswerRe: error in oledb connection string Pin
Steve Pullan30-May-06 19:30
Steve Pullan30-May-06 19:30 
GeneralRe: error in oledb connection string Pin
thomas_joyee30-May-06 19:43
thomas_joyee30-May-06 19:43 
GeneralRe: error in oledb connection string Pin
Steve Pullan30-May-06 20:10
Steve Pullan30-May-06 20:10 
GeneralRe: error in oledb connection string Pin
thomas_joyee30-May-06 20:21
thomas_joyee30-May-06 20:21 
GeneralRe: error in oledb connection string Pin
Steve Pullan30-May-06 20:58
Steve Pullan30-May-06 20:58 
Questionobject reference not set to instance of an object Pin
uglyeyes30-May-06 18:19
uglyeyes30-May-06 18:19 
Hi I am trying to place placeholder template within a datalist for some reason i am getting this error that says object reference not set to instance of an object the

aspx page is:

<asp:datalist id="dlScHead" runat="server" showfooter="False" showheader="False" cellspacing="0"
="" cellpadding="0" width="100%">
<itemtemplate>


<%# ctype(DataBinder.Eval(Container.DataItem,"ScoreCardID"),string) %>
  
<%# ctype(DataBinder.Eval(Container.DataItem,"scorecarddesc"),string) %>



<%# ctype(DataBinder.Eval(Container.DataItem,"BusinessGoal"),string) %>




<asp:datalist id="dlScChart" width="100%" datasource="<%# (GetRecords(Cstr(DataBinder.Eval(Container.DataItem, "ScoreCardId")))) %>" runat="server">
<itemstyle verticalalign="Top" backcolor="#EEEEEE">
<itemtemplate>

<asp:placeholder id="Placeholder1" runat="server">




<%# Server.htmlDecode(DataBinder.Eval(Container.DataItem,"Quarter1").tostring()) %>




<%# Server.htmlDecode(DataBinder.Eval(Container.DataItem,"Quarter2").tostring()) %>




<%# Server.htmlDecode(DataBinder.Eval(Container.DataItem,"Quarter3").tostring()) %>




<%# Server.htmlDecode(DataBinder.Eval(Container.DataItem,"Quarter4").tostring()) %>








================================================

and code behind
--------------------

in page load event i am doing

dlScHead.DataSource = GetRecords(Nothing)
dlScHead.DataBind()

and in function getRecords i am doing

Function GetRecords(ByVal scID As String) As SqlDataReader
Dim bizProgName As String = Request.QueryString("bizProgId")
Dim CommandText As String


Try
objConn = New SqlConnection(dbPath)
objConn.Open()

If scID = Nothing Then
Dim da As New SqlDataAdapter
da.SelectCommand = New SqlCommand
da.SelectCommand.Connection = objConn
da.SelectCommand.CommandText = "select scorecardId,bizProgId,scorecarddesc,businessgoal,strategy,quarter1,quarter2,quarter3,quarter4 from textData where bizProgID='" & Request.QueryString("bizProgId") & "'"
dr = da.SelectCommand.ExecuteReader(CommandBehavior.CloseConnection)
If dr.HasRows Then
'lblError.Text = ""
Else
'lblError.Text = "No records returned"
End If
GetRecords = dr

Else

cmd = New SqlCommand("select distinct measure_id from measuredata where scoreCardId = '" & scID & "'", objConn)
Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim dtid As New DataTable("measureid")

da.fill(dtid)

'select all columns with id
Dim cmd1 As SqlCommand = New SqlCommand("select * from measuredata where scorecardid = '" & scID & "'", objConn)

Dim da1 As SqlDataAdapter = New SqlDataAdapter(cmd1)
Dim dt As New DataTable("measuresource")

da1.Fill(dt)

Dim datarow As DataRow

For Each datarow In dtid.Rows
Dim chart As New DataGrid
Dim myview As New DataView(dt)

' dim chart as new mycos.mycoschartweb
myview.RowFilter = String.Format("measure_id='{0}'", datarow.Item("measure_id"))

chart.DataSource = myview
chart.DataBind()
Dim i As Integer
For i = 0 To dlScChart.Items.Count - 1
dlScChart.Items(i).FindControl("placeholder1").Controls.Add(chart)
Next
Next datarow


' GetRecords = PlaceHolder1.FindControl("placeholder1")


End If

Catch ex As Exception
Response.Write("error on child-- here" + ex.ToString + "
")
Finally



End Try
End Function

i am getting error in


dlScChart.Items(i).FindControl("placeholder1").Controls.Add(chart)



please help thanks
AnswerRe: object reference not set to instance of an object Pin
Christian Graus30-May-06 18:21
protectorChristian Graus30-May-06 18:21 
AnswerRe: object reference not set to instance of an object Pin
Steve Pullan30-May-06 18:34
Steve Pullan30-May-06 18:34 
GeneralRe: object reference not set to instance of an object Pin
uglyeyes30-May-06 21:13
uglyeyes30-May-06 21:13 
GeneralRe: object reference not set to instance of an object Pin
Steve Pullan30-May-06 21:25
Steve Pullan30-May-06 21:25 
QuestionHelp Pin
zenithmaximus30-May-06 18:00
zenithmaximus30-May-06 18:00 
AnswerRe: Help Pin
Christian Graus30-May-06 18:19
protectorChristian Graus30-May-06 18:19 
QuestionHow to create batch file Pin
andylimjp30-May-06 17:15
andylimjp30-May-06 17:15 
AnswerRe: How to create batch file Pin
Christian Graus30-May-06 18:20
protectorChristian Graus30-May-06 18:20 
AnswerRe: How to create batch file Pin
Chatura Dilan30-May-06 18:36
Chatura Dilan30-May-06 18:36 
QuestionUnicode characters Pin
Chatura Dilan30-May-06 15:23
Chatura Dilan30-May-06 15:23 
GeneralSearch or filter records on a form [modified] Pin
penguin500030-May-06 11:42
penguin500030-May-06 11:42 
GeneralRe: Search or filter records on a form [modified] Pin
mr_1234531-May-06 13:44
mr_1234531-May-06 13:44 
GeneralRe: Search or filter records on a form [modified] Pin
penguin500031-May-06 19:36
penguin500031-May-06 19:36 
Questionhow to find record in datagrid Pin
Syed Ali Raza30-May-06 10:28
Syed Ali Raza30-May-06 10:28 
AnswerRe: how to find record in datagrid Pin
Leeland30-May-06 11:01
Leeland30-May-06 11:01 
GeneralRe: how to find record in datagrid Pin
Syed Ali Raza30-May-06 12:06
Syed Ali Raza30-May-06 12:06 
AnswerRe: how to find record in datagrid [modified] Pin
mr_1234530-May-06 16:26
mr_1234530-May-06 16:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.