Теперь у меня есть элементы управления, которые находятся в моей панели обновления, и меняют данные в моем gridview, они работают нормально, но потом я подумал, что было бы здорово иметь элементы управления в заголовке моего gridview. Но когда я добавляю их в свой заголовок и нажимаю кнопку/запускаю функцию, я получаю, что не удалось загрузить ошибку в представлении. Любые идеи или советы, которые я читаю в Интернете, но все же не могу заставить его работать.не удалось загрузить viewstate, поместив элементы управления в заголовок gridview
Function toptable()
Dim reader As SqlDataReader
cmd.Parameters.AddWithValue("@yeartoget", DropDownList1.SelectedValue)
cmd.Parameters.AddWithValue("@mode", RadioButtonList1.SelectedValue)
If TextBox1.Text = "" Then
Dim d As Date = Date.Today
TextBox1.Text = d.AddDays(-1)
End If
Dim pyear As Date
Dim pyear1 As Date
pyear = TextBox1.Text
Dim year1 As Int16
year1 = (pyear.Year - DropDownList1.SelectedValue)
If pyear.Year <> Now.Year Then
pyear1 = (pyear.AddYears(-(year1 + 1)))
Else
pyear1 = (pyear.AddYears(-year1))
End If
cmd.Parameters.AddWithValue("@current", TextBox1.Text)
cmd.Parameters.AddWithValue("@search", pyear1)
cmd.CommandText = "asofworking"
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = conn
cmd.CommandTimeout = 300
conn.Open()
reader = cmd.ExecuteReader()
Dim myTable As DataTable = New DataTable()
myTable.Load(reader)
conn.Close()
Dim currentppax As New DataColumn
currentppax = New DataColumn("AVGPPAX", GetType(Double))
currentppax.Expression = "IIf([CurrentPAX] = 0, 0, [CurrentSales]/[CurrentPAX])"
Dim selectedppax As New DataColumn
selectedppax = New DataColumn("AVGpPAX1", GetType(Double))
selectedppax.Expression = "asofSales/asofPAX"
Dim projsales As New DataColumn
projsales = New DataColumn("ProjSales", GetType(Double))
projsales.Expression = "IIF([PercentSales] = 0, [CurrentSales], [CurrentSales]/[PercentSales])"
Dim projpax As New DataColumn
projpax = New DataColumn("ProjPAX", GetType(Double))
projpax.Expression = "IIF([PercentPAX] = 0, [CurrentPAX], [CurrentPAX]/[percentpax])"
Dim remainingsales As New DataColumn
remainingsales = New DataColumn("remainingsales", GetType(Double))
remainingsales.Expression = "ProjSales - currentsales"
Dim remainingpax As New DataColumn
remainingpax = New DataColumn("remainingpax", GetType(Double))
remainingpax.Expression = "Projpax - currentpax"
Dim movementpax As New DataColumn
movementpax = New DataColumn("movementPAX", GetType(Double))
movementpax.Expression = "IIF([ASOFPAX] = 0, 2,(CurrentPAX/[ASOFPAX]))-1"
Dim movementsales As New DataColumn
movementsales = New DataColumn("movementsales", GetType(Double))
movementsales.Expression = "IIF([ASOFsales] = 0, 2,(Currentsales/[ASOFsales]))-1"
myTable.Columns.Add(selectedppax)
myTable.Columns.Add(currentppax)
myTable.Columns.Add(projsales)
myTable.Columns.Add(projpax)
myTable.Columns.Add(remainingsales)
myTable.Columns.Add(remainingpax)
myTable.Columns.Add(movementsales)
myTable.Columns.Add(movementpax)
GridView1.DataSource = myTable
GridView1.DataBind()
Dim row As New GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal)
'spanned cell that will span the columns I don't want to give the additional header
Dim compare As TableCell = New TableHeaderCell()
compare.ColumnSpan = 8
row.Cells.Add(compare)
'compare.Text = DropDownList1.Text
compare.controls.add(DropDownList1.Text)
'spanned cell that will span the columns i want to give the additional header
Dim current As TableCell = New TableHeaderCell()
current.ColumnSpan = 3
'current.Text = Year(Now())
row.Cells.Add(current)
current.controls.add(textbox1)
Dim Projection As TableCell = New TableHeaderCell()
Projection.ColumnSpan = 4
Projection.Text = "Projections"
row.Cells.Add(Projection)
Dim Movements As TableCell = New TableHeaderCell()
Movements.ColumnSpan = 2
Movements.Text = "Movement"
row.Cells.Add(Movements)
'Add the new row to the gridview as the master header row
'A table is the only Control (index[0]) in a GridView
DirectCast(GridView1.Controls(0), Table).Rows.AddAt(0, row)
Label2.Text = RadioButtonList1.Text + " - " + TextBox1.Text
If CheckBox1.Checked Then
If Label2.Text <> Label4.Text Then
bottomtable()
End If
End If
End Function
хм насчет во время выполнения, shoild я попробовать и поместите его в функцию – MyHeadHurts
Что вы имеете в виду с 'on runtime'? Эти функции вызывают во время выполнения. –
извините, я хотел сказать, что могу поместить это в функцию вместо строки, созданной – MyHeadHurts