Click here to Skip to main content
15,890,717 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Retriving,Converting and Embedding Images Pin
isroavi27-Apr-06 20:59
isroavi27-Apr-06 20:59 
Questionlistview event - item checked Pin
isroavi27-Apr-06 20:23
isroavi27-Apr-06 20:23 
QuestionCan we Make Graphs in VB.net? Pin
jkrao27-Apr-06 20:21
jkrao27-Apr-06 20:21 
AnswerRe: Can we Make Graphs in VB.net? Pin
isroavi27-Apr-06 20:25
isroavi27-Apr-06 20:25 
AnswerRe: Can we Make Graphs in VB.net? Pin
Mandar Patankar28-Apr-06 10:48
Mandar Patankar28-Apr-06 10:48 
Questionunit conversion in vb.net Pin
wilde27-Apr-06 17:48
wilde27-Apr-06 17:48 
AnswerRe: unit conversion in vb.net Pin
Christian Graus27-Apr-06 17:54
protectorChristian Graus27-Apr-06 17:54 
Questionadding dynamic datagrid inside a datalist web control Pin
bshresth27-Apr-06 17:13
bshresth27-Apr-06 17:13 
Hi All,

My problem is something like this,

I have a datalist where i want to add a dynamic datagrid. to better understand my problem please see the code below.

in vb file
-----------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dlScHead.DataSource = GetRecords(Nothing)
dlScHead.DataBind()

End Sub
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 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" + ex.ToString)
Finally



End Try
End Function

------------
in aspx page.
=============

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

<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()) %>







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

I am getting Null reference exception/object not set to instance of an object in my vb file in

chart.DataSource = myView

i really dont know what i am doing wrong or is it looking for the IDs of the datagrids

please help its eating my head.

many many thanks in forward.

Bikash
QuestionNeed help in converting a code snippet from C# to VB.NET. Pin
Slow Learner27-Apr-06 15:47
Slow Learner27-Apr-06 15:47 
AnswerRe: Need help in converting a code snippet from C# to VB.NET. Pin
atregent27-Apr-06 17:38
atregent27-Apr-06 17:38 
AnswerRe: Need help in converting a code snippet from C# to VB.NET. Pin
Kevin McFarlane28-Apr-06 11:40
Kevin McFarlane28-Apr-06 11:40 
QuestionAny easy way : Random Number Range Pin
Chatura Dilan27-Apr-06 15:40
Chatura Dilan27-Apr-06 15:40 
AnswerRe: Any easy way : Random Number Range Pin
Christian Graus27-Apr-06 17:51
protectorChristian Graus27-Apr-06 17:51 
GeneralRe: Any easy way : Random Number Range Pin
Chatura Dilan27-Apr-06 18:45
Chatura Dilan27-Apr-06 18:45 
GeneralRe: Any easy way : Random Number Range Pin
Christian Graus27-Apr-06 19:00
protectorChristian Graus27-Apr-06 19:00 
AnswerRe: Any easy way : Random Number Range Pin
Roy Heil28-Apr-06 4:03
professionalRoy Heil28-Apr-06 4:03 
AnswerRe: Any easy way : Random Number Range Pin
Chatura Dilan28-Apr-06 15:06
Chatura Dilan28-Apr-06 15:06 
QuestionProblem with Deployment, Win Installer, Setup Pin
HamCoder27-Apr-06 12:00
HamCoder27-Apr-06 12:00 
AnswerRe: Problem with Deployment, Win Installer, Setup Pin
Andrew Bleakley27-Apr-06 12:35
Andrew Bleakley27-Apr-06 12:35 
GeneralRe: Problem with Deployment, Win Installer, Setup Pin
HamCoder28-Apr-06 9:40
HamCoder28-Apr-06 9:40 
QuestionStarting a process from a Windows Service Pin
dlarkin7727-Apr-06 5:22
dlarkin7727-Apr-06 5:22 
AnswerRe: Starting a process from a Windows Service Pin
H@is@here27-Apr-06 23:30
H@is@here27-Apr-06 23:30 
AnswerRe: Starting a process from a Windows Service Pin
spaceus27-Apr-06 23:56
spaceus27-Apr-06 23:56 
QuestionFind File Owner Using .NET 2.0 Pin
is251rd27-Apr-06 5:12
is251rd27-Apr-06 5:12 
AnswerRe: Find File Owner Using .NET 2.0 Pin
kasik27-Apr-06 5:32
kasik27-Apr-06 5:32 

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.