I am binding a datatable to an asp.net chart but want to set the value of the label to a different dataitem (called ResLabelText) than used for the x or y axis. Can this be done? My databinding code is as follows:
chartRes.Series("Month").XValueMember = "MonthName"
chartRes.Series("Month").YValueMembers = "Res"
chartRes.Series("Month").Label = "ResLabelText"
chartRes.Series("Month").ToolTip = "#VALX"
chartRes.DataSource = dt
chartRes.DataBind()
Correct way:
For Each row In dt.Rows
Dim point = New DataPoint()
point.SetValueXY(row.Item("MonthName"), row.Item("Res"))
point.Label = row.Item("LabelRes")
point.ToolTip = row.Item("MonthName")
chartRes.Series("Month").Points.Add(point)
Next
Related
Hi I am trying to add two controls into a table cell the code is below. Unfortunately the hyperlink is always outside the table cell, whilst the label is inside. Individually they are working fine but together not so good, could somebody help me please.
Dim iCell As New TableCell
Dim lbl As New Label
lbl.Height = Unit.Pixel(100)
lbl.Width = Unit.Pixel(150)
lbl.Style.Add("padding", "5px")
lbl.Style.Add("border-radius", "10px")
lbl.BorderStyle = BorderStyle.Solid
lbl.BorderWidth = Unit.Pixel(1)
lbl.BorderColor = Color.Black
lbl.Font.Size = 9
lbl.Text = "Event: " & dt.Rows(y).Item("eventname")
lbl.BackColor = ColorTranslator.FromHtml(dt.Rows(y).Item("roomcolor"))
Dim hyp As New HyperLink
hyp.Font.Size = 9
hyp.Text = "Modify"
hyp.NavigateUrl = "modify.aspx"
iCell.Controls.Add(lbl)
iCell.Controls.Add(hyp)
iCell.VerticalAlign = VerticalAlign.Top
tRow.Cells.Add(iCell)
can I add my drop down list twice in different cells? Now it works only for the last cell, so I have one drop down list in las cell. Must I create each time new drop down list or how can I make it?
Thanks in advance
Dim ddltest As New DropDownList
ddltest.ID = "ddltest"
ddltest.Width = Unit.Pixel(270)
ddltest.Enabled = False
ddltest.Items.Add(New ListItem("text1", "value1"))
ddltest.Items.Add(New ListItem("text2", "value2"))
ddltest.SelectedItem.Text = ddltest.Items.FindByValue("value2").Text
row01.Cells.Add(New TableCell)
row01.Cells(1).Width = Unit.Pixel(300)
row01.Cells(1).Controls.Add(ddltest)
ddltest.SelectedItem.Text = ddltest.Items.FindByValue("value1").Text
row01.Cells.Add(New TableCell)
row01.Cells(2).Width = Unit.Pixel(300)
row01.Cells(2).Controls.Add(ddltest)
Create you DDL in a function and then add it with different IDs to your cells
Private Function DDLCreate(ByVal Id As String) As DropDownList
Dim ddltest As New DropDownList
ddltest.ID = Id
ddltest.Width = Unit.Pixel(270)
ddltest.Enabled = False
ddltest.Items.Add(New ListItem("text1", "value1"))
ddltest.Items.Add(New ListItem("text2", "value2"))
Return ddltest
End Function
and then you can use it as often as you want like
row01.Cells(2).Controls.Add(DDLCreate("DDL1"))
row01.Cells(3).Controls.Add(DDLCreate("DDL2"))
Cheers Alex
I'm trying to add a manually created chart to a placeholder but when i look at the output all i get is a blank.. I am getting the data from a dataset datatable that is the last table in the dataset. I only has two colums "Industry" and "industryTheta" any help is much appreciated. I'm not sure whats wrong here
Dim chrt As New Chart
chrt.ID = "dynChart"
chrt.Height = Unit.Pixel(1000)
chrt.Width = Unit.Pixel(1000)
chrt.BackImageWrapMode = ChartImageWrapMode.Scaled
chrt.BorderlineColor = Color.Black
chrt.ImageLocation = "~/TempImages/ChartPic_#SEQ(300,3)"
chrt.BackGradientStyle = GradientStyle.None
Dim ca As New ChartArea
ca.Name = "IndustryTheta"
ca.AlignmentOrientation = AreaAlignmentOrientations.All
ca.AlignmentStyle = AreaAlignmentStyles.All
ca.Area3DStyle.Enable3D = True
ca.Area3DStyle.LightStyle = LightStyle.Realistic
ca.Area3DStyle.Inclination = 30
ca.BackHatchStyle = ChartHatchStyle.None
chrt.ChartAreas.Add(ca)
Dim sers As New Series
sers.Name = "IndustryName"
sers.ChartType = SeriesChartType.Pie
sers.Label = "#VALX, #PERCENT"
sers.LabelAngle = 90
sers.IsXValueIndexed = True
sers.IsValueShownAsLabel = True
sers.XAxisType = AxisType.Primary
sers.YAxisType = AxisType.Primary
sers.YValuesPerPoint = 1
sers.XValueMember = "Industry"
sers.YValueMembers = "IndustryTheta"
chrt.Series.Add(sers)
For Each dr As DataRow In table.Rows
Dim p As New DataPoint
p.SetValueY(Convert.ToInt32(dr.Item("IndustryTheta")))
p.AxisLabel = dr.Item("Industry")
sers.Points.Add(p)
Next
chrt.DataBind()
dynamicGrids.Controls.Add(chrt)
Most likely your problem is with when you are calling your function in the page life cycle. Please refer to this information to learn more about it.
In order to address dynamic controls in asp.net please refer to this for more information on dynamic controls.
how to identify label control in foreach Silverlight Datagrid
For Each item In TaskDataGrid.ItemsSource
TryCast(TryCast(item, StackPanel).Children(2), Label).Content = "New Text"
Next
I have label control in 2 nd Column how to identify and assign the value
This is working fine..
For Each rowItem In TaskDataGrid.ItemsSource
' Ensures that all rows are loaded.
TaskDataGrid.ScrollIntoView(rowItem, TaskDataGrid.Columns.Last())
Dim fe As FrameworkElement = TaskDataGrid.Columns(2).GetCellContent(rowItem)
Dim fe1 As FrameworkElement = TaskDataGrid.Columns(1).GetCellContent(rowItem)
Dim gridCmbo As Grid = DirectCast(fe, Grid)
Dim gridCmbo1 As Grid = DirectCast(fe1, Grid)
Dim lbltaskId As Label = CType(gridCmbo1.FindName("lbltaskId"), Label)
Dim lblBaseReceipt As Label = CType(gridCmbo.FindName("lblBaseReceipt"), Label)
Next
I am trying programatically add a check box column to a grid view. This grid view has multiple other columns but I only want the check box column to be editable. The only examples I have seen require that I add an "Edit" link to each row. I would like for the check box column to be editable by default, without the need for a link. The check box should also support autopost backs. Anyone have any suggestions? Below is what I have so far:
Dim gv As New GridView
With gv
.ID = "gridViewFoundUsers"
.AutoGenerateColumns = False
.DataKeyNames = New String() {"UserId"}
.GridLines = GridLines.Both
.AllowSorting = True
.AllowPaging = True
.PageSize = numRows
.Width = tableWidth
.BorderColor = Drawing.ColorTranslator.FromHtml("#808080")
.AutoGenerateEditButton = True
.HeaderStyle.CssClass = foundUserHeadStyle
.RowStyle.CssClass = foundUserEvenRows
.Columns.Clear()
Dim UserIdTF As New BoundField
With UserIdTF
.DataField = "UserId"
.HeaderText = "UserID"
.SortExpression = "UserId"
.ItemStyle.Wrap = True
.ItemStyle.Width = 100
End With
Dim DomainTF As New BoundField
With DomainTF
.HeaderText = "Domain"
.DataField = "Domain"
.SortExpression = "Domain"
.ItemStyle.Wrap = False
.HeaderStyle.Font.Underline = False
End With
Dim SelectUserTF As New CheckBoxField
With SelectUserTF
.HeaderText = "Select User"
.ItemStyle.Wrap = False
.DataField = "isSelected"
End With
.Columns.Add(UserIdTF)
.Columns.Add(DomainTF)
.Columns.Add(SelectUserTF)
End With
The gridview is part of a composite server control, so there is no client side code pages.
Thanks!