How to update devexpress gridview data column value automatically if condition is met? - vb.net

I need to update devexpress gridview data column value automatically if condition is met. I tried to implement it using HtmldatacellPrepared
but there is error at line e.GetValue("Status") = "Delay" : Expression is a value and therefore cannot be the target of an assignment. Is there any other method to use to implement this?
Protected Sub Grid_HtmldatacellPrepared(sender As Object, e As ASPxGridViewTableDataCellEventArgs)
if e.GetValue("Forecast") IsNot DBNull.Value Then
If e.DataColumn.VisibleIndex = 9 Then
If e.GetValue("Forecast") > Date.Now Then
e.GetValue("Status") = "Delay"
End if
End If
End If
End Sub

Use the ASPxGridView.CustomColumnDisplayText event instead of the ASPxGridView.HtmlDataCellPrepared one, and set the EventArgs e.DisplayText property. Check out my answer here.

e.GetValue("...") is a function so you cannot assign value to it.
I don't have DevExpress component handy to test but based on their online doc, I draft below how to set the cell value.
In order to set the value of the "Status" cell, handle the grid's CustomColumnDisplayText event. Detect if the target cell (i.e "Status") is currently being processed and set the value using e.DisplayText property.
Protected Sub ASPxGridView1_CustomColumnDisplayText(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridViewColumnDisplayTextEventArgs) Handles ASPxGridView1.CustomColumnDisplayText
If e.Column.FieldName = "Status" Then
Dim grid = DirectCast(sender, ASPxGridView)
Dim forecast As Object = grid.GetRowValues(e.VisibleRowIndex,"Forecast")
If forecast IsNot DBNull.Value AndAlso CDate(forecast) > Date.Now Then
e.DisplayText = "Delay"
End If
End If
End Sub
Hopefully that will give you rough idea.

Related

Revert the DataGridViewCell to the value before it was changed by the user

I have a DataGridView like this:
The Quantidade column can be changed by the user and the others are read only. I came up with this code that if the user changes the value of Quantidade manually on the DataGridView it checks the database to see if it has enough in stock. So if the value inputted by the user is less than the total in stock it changes normally but my question is if the user inputs a value bigger than the value in stock I want the DataGridViewCell to return to the value before it has been changed by the user.
Any ideas on how to do this?
Here is the code of the event:
Private Sub DataGridView1_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
'this part is to check the total of the product in the db
Dim Produtoid As String = DataGridView1.Rows(e.RowIndex).Cells(0).Value
Dim tabelaqndDisponivel As DataTable = CAD.GetData("SELECT quantidadeExistenteProduto FROM Produto where idProduto = " & Produtoid)
'qntDisponivel is a integer that holds the total quantity of the product in the db
Dim qntDisponivel As Integer = tabelaqndDisponivel.Rows(0).Item(0)
If DataGridView1.Rows(e.RowIndex).Cells(2).Value <= qntDisponivel Then
'inserts normally
Else
'now here the value on cell "quantidade" should revert
End If
End Sub
Note that This DataGridView is pretty simple. It takes the value from the ComboBox Produto and text from the TextBox Quantidade
An alternative that I often use is to save it to the .Tag, every object has a .Tag and it saves declaring a variable globally if you want to use it throughout the code.
Whilst not necessarily shorter code it does prove very useful at times and overall is tidier in my opinion as you don't have to declare a variable (you can save it to the cell or row .Tag but that is even longer code).
Usage in your application:
Private Sub dataGridView1_CellValidating(ByVal sender As Object, ByVal e As DataGridViewCellValidatingEventArgs) Handles DataGridView1.CellValidating
DataGridView1.Tag = DataGridView1.Rows(e.RowIndex).Cells(2).Value
End Sub
Retrieval:
Else
'now here the value on cell "quantidade" reverts to the value before being changed
DataGridView1.Rows(e.RowIndex).Cells(2).Value = DataGridView1.Tag
End If
My answer is to provide some help on a few issues with your code. Since we have already discussed your question at hand and a fix has been implemented I think it would be worthwhile addressing these issues.
Turn Option Strict On:
Restricts implicit data type conversions to only widening conversions, disallows late binding, and disallows implicit typing that results in an Object type.
First DataGridView1.Rows(e.RowIndex).Cells(0).Value is type Object and so to resolve this we need to append .ToString() to it like so:
Dim Produtoid As String = DataGridView1.Rows(e.RowIndex).Cells(0).Value.ToString()
Second tabelaqndDisponivel.Rows(0).Item(0) and DataGridView1.Rows(e.RowIndex).Cells(2).Value are too type Object. With these I would handle using Integer.TryParse. You can then also check the Integer values correctly:
Dim qntDisponivel As Integer = 0
Dim qnt As Integer = 0 'You can give this a more meaningful name
If Integer.TryParse(tabelaqndDisponivel.Rows(0).Item(0).ToString(), qntDisponivel) AndAlso
Integer.TryParse(DataGridView1.Rows(e.RowIndex).Cells(2).Value.ToString(), qnt) Then
If qnt <= qntDisponivel Then
'inserts normally
Else
'now here the value on cell "quantidade" reverts to the value before being changed
DataGridView1.Rows(e.RowIndex).Cells(2).Value = valorqnt
End If
Else
'Haven't been able to check so revert
DataGridView1.Rows(e.RowIndex).Cells(2).Value = valorqnt
End If
Thirdly DataGridView1.Rows(e.RowIndex).Cells(2).Value inside your CellValidating method is again type Object. Change using Integer.TryParse:
Integer.TryParse(DataGridView1.Rows(e.RowIndex).Cells(2).Value.ToString(), valorqnt)
Lastly your SQL statement is open to SQL injection. You would need to look into SQL parameters. It's quite difficult to provide much help in this area as I can't see what GetData does and it would be outside the scope of this question but it is definitely worth a mention.
So what I did here was create a variable Private valorqnt As Integer and on the event CellValidating I saved the value (before being changed by the user) into it.
Code:
Private Sub dataGridView1_CellValidating(ByVal sender As Object, ByVal e As DataGridViewCellValidatingEventArgs) Handles DataGridView1.CellValidating
valorqnt = DataGridView1.Rows(e.RowIndex).Cells(2).Value
End Sub
This way I have the value of the cell before being changed. Now on the CellValueChanged event I added DataGridView1.Rows(e.RowIndex).Cells(2).Value = valorqnt so I could revert the value.
Code:
Private Sub DataGridView1_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
'this part is to check the total of the product in the db
Dim Produtoid As String = DataGridView1.Rows(e.RowIndex).Cells(0).Value
Dim tabelaqndDisponivel As DataTable = CAD.GetData("SELECT quantidadeExistenteProduto FROM Produto where idProduto = " & Produtoid)
'qntDisponivel is a integer that holds the total quantity of the product in the db
Dim qntDisponivel As Integer = tabelaqndDisponivel.Rows(0).Item(0)
If DataGridView1.Rows(e.RowIndex).Cells(2).Value <= qntDisponivel Then
'inserts normally
Else
'now here the value on cell "quantidade" reverts to the value before being changed
DataGridView1.Rows(e.RowIndex).Cells(2).Value = valorqnt
End If
End Sub

VB.NET datagridview one-to-one mapping of combobox

I have a datagridview with two textbox columns and one combobox column. The combobox's DataSource is bound to enums for the values of the dropdown. The datagridview's DataSource is bound to a custom class with datatypes of string, string and enum.
The first two columns are pre-populated with values and in the third column the user must select a value from the dropdown. All this is working excellent so far except....
The combobox field should be a one-to-one kind of mapping, meaning no two comboboxes should have the same value. I am really not sure how to implement this kind of behavior. Should the chosen value be removed from the remaining dropdowns? should the chosen value remain in the dropdown and just give an error when two of the same are selected?
Any ideas and how to implement these ideas will be of great help.
Thanks
note the only acceptable value that can be used more than once is 'None'
I have an idea based off your intent to possibly remove the chosen value from the remaining dropdowns.
I have a class called Runner which has a similar setup to your example.
Public Class Runner
Public Property FirstName As String
Public Property LastName As String
Public Property Placement As Result
Public Sub New(fn As String, ln As String)
FirstName = fn
LastName = ln
Placement = Result.None
End Sub
End Class
I also have an enum called Result which will get populated into the ComboBoxCell:
Public Enum Result
None = 0
Bronze = 1
Silver = 2
Gold = 3
End Enum
When I create data objects and bind them to the DataGridView, I do so like this (note - Placements is a global List(Of Result) and Runners is a global List(Of Runner):
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Placements.Add(Result.None)
Placements.Add(Result.Bronze)
Placements.Add(Result.Silver)
Placements.Add(Result.Gold)
Runners.Add(New Runner("John", "Smith"))
Runners.Add(New Runner("Jane", "Doe"))
Runners.Add(New Runner("Bill", "Jones"))
Column1.DataPropertyName = "FirstName"
Column2.DataPropertyName = "LastName"
Column3.DataPropertyName = "Placement"
Column3.DataSource = Placements
DataGridView1.DataSource = Runners
End Sub
Now, whenever the value of a cell in the ComboBoxColumn changes, you remove the new value from the list that contains the enums:
Private Sub DataGridView1_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
If (e.RowIndex > -1 And e.ColumnIndex = 2) Then
Dim currentvalue As Result = DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
If currentvalue <> Result.None Then
Placements.Remove(currentvalue)
End If
End If
End Sub
Be careful when changing drop down selections... as per this Discussion, you have to trick the DataGridView into committing values as soon as the ComboBox value changes. I used an answer from that discussion and did something like this:
Private Sub DataGridView1_CurrentCellDirtyStateChanged(sender As Object, e As EventArgs) Handles DataGridView1.CurrentCellDirtyStateChanged
Dim col As DataGridViewColumn = DataGridView1.Columns(DataGridView1.CurrentCell.ColumnIndex)
If col.Name = "Column3" Then
DataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit)
Dim selected As DataGridViewCell = DataGridView1.CurrentCell
DataGridView1.CurrentCell = Nothing //This line and the next one simply hide
DataGridView1.CurrentCell = selected //an odd display effect that occurs
//because we remove a value and change the
//selection at the same time
End If
End Sub
Finally, you want to handle the DataError event for the DataGridView and leave it blank so that you don't get Exceptions thrown at you when removing values from your list of enums.
This gets you about 90% of the way there. It will not re-add items to the list when you change a value. For example if I change from Gold to Silver, Gold should be added back to the list. You can probably figure out what events to handle to get the old value and the new one, and insert the old value back into the list at the correct index based on its enum value.
I decided to use the CellValidating event of the DataGridView to check whether or not the same value is selected more than once. If it is then a error message is displayed in the row header column.
The combobox in error will not lose focus until the error is resolved.
Private Sub DataGridView1_CellValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles DataGridView1.CellValidating
Dim headerText As String = DataGridView1.Columns(e.ColumnIndex).HeaderText
'Abort validation if cell is not in the Mapping column.
If Not headerText.Equals("Column Mapping") Then Return
'Clear error on current row.
DataGridView1.Rows(e.RowIndex).ErrorText = Nothing
e.Cancel = False
Dim newMappingValue As XmlElement = DirectCast([Enum].Parse(GetType(XmlElement), e.FormattedValue), XmlElement)
' Abort validation if cell value equal XmlElement.None
If newMappingValue.Equals(XmlElement.None) Then Return
For Each dgvRow As DataGridViewRow In DataGridView1.Rows
Dim currentMappingValue As XmlElement = dgvRow.Cells.Item(headerText).Value
If dgvRow.Index <> e.RowIndex Then
If currentMappingValue.Equals(newMappingValue) Then
DataGridView1.Rows(e.RowIndex).ErrorText = "Value already selected, please select a different value."
e.Cancel = True
End If
End If
Next
End Sub

how to put search functionality in dataGridView in vb.NET

How can I select a single cell from selected row in datagridView and after selecting that I want to put simple search functionality (like we have in our windows folders-typing any characters and search should work)?
I do not really understand your question. If you want to select one cell, you can use the celldoubleclick event for exemple. And the to get the selected cell, use e.rowindex and e.columnindex which will give you the row and the column where the cell is located.
You can try this as a possible solution.
Dim nwData as CustomersDataSet = CustomersDataSet.GetCustomers()
m_CustomersGrid.DataSource = m_CustomersBindingSource
m_CustomersBindingSource.DataSource = nwData.Customers
Then you can sort using the BindingSource.
CustomersBindingSource.Sort = "ContactName ASC"
And you can find using the BindingSource.
Dim index as integer = _
CustomersBindingSource.Find("CompanyName", CompanyNameTextBox.Text)
If index <-1 then 'it was found; move to that position
CustomersBindingSource.Position = index
End If
You could then populate:
CustomersBindingSource.Find("CompanyName", CompanyNameTextBox.Text)
with the keys pressed in the cell by capturing them by utilizing:
Private Sub DataGridView1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyUp
Dim dgv As DataGridView = TryCast(sender, DataGridView)
If dgv IsNot Nothing Then
'You will need some logic here to determine how long to wait between keyups
'Perhaps a timer that ticks every500 milliseconds and reset on keyup.
e.KeyData
End If
End Sub
I found the original Biding Source Logic at : This Location

In vb.net, how do I force validating controls within a (winform) datarepeater after the data is populated?

I have a form with a datarepeater that contains various controls (i.e. datetimepickers, text boxes, combo box) that are populated via a binding source. I also have other controls on the form that are not part of the data repeater.
I would like to force validating all controls after the data is populated. I have successfully forced validating the non-datarepeater controls using Me.ValidateChildren() at the end of my load event. However, it does not fire the validating events for the controls within the data repeater.
I have unsuccessfully tried many different attempts to set and move focus within the datarepeater controls trying to get the validating events kicked off. I am not sure where would be the best place (e.g. in drawItem? in ItemCloned?) to place the code and what it should be exactly. Here was my latest attempt:
Private Sub DataRepeater1_DrawItem(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs) _
Handles DataRepeater1.DrawItem
For i = 0 To e.DataRepeaterItem.Controls.Count - 1
e.DataRepeaterItem.Controls.Item(i).Focus()
e.DataRepeaterItem.Controls.Item(0).Focus()
Next
Note: I successfully handled the validating events in the data repeater caused by user input errors. However, I have the unusual situation that the data coming into my form is already bad for some of the controls. The purpose of the form is to validate the data coming in to it and from user-input.
Thanks in advance for any help. I am newbie with vb.net.
Have you tried calling
DataRepeater1.ValidateChildren()
after calling form's Me.ValidateChildren()
MSDN link
EDIT:
Can you try this
Private Shared Function ValidateAllChildern(cc As ContainerControl) As Boolean
Return cc.ValidateChildren() And cc.Controls.OfType(Of ContainerControl)().[Select](Function(c) ValidateAllChildern(c)).Aggregate(True, Function(x, y) x And y)
End Function
and call
ValidateAllChildren(Me)
Here is what I ended up using and it worked great. Basically, you can call the same validation functions in cellformatting and cellvalidating. Cell formatting handles the validation on initial load. Cell validating handles validation on user changes. Also, if you want a global change on user entry (e.g. change to upper case), use EditControlShowing.
A nice feature too is that it shows the little error icon in the cell the error occurred on. Here are the details, fyi.
'handles dgv validation on initial load
Private Sub dgvExample_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) _
Handles dgvExample.CellFormatting
Dim results As String = ""
If e.RowIndex <> -1 Then
Select Case e.ColumnIndex
Case 1, 2 'starting and ending service dates
results = ValidateDate(e.Value)
If results = "" Then
results = ValidateDateRange(e.RowIndex)
End If
Case 11 'billed amount
results = ValidateBilledAmount(e.RowIndex)
End Select
dgvExample.Rows(e.RowIndex).Cells(e.ColumnIndex).ErrorText = results
End If
End Sub
'handles dgv validation from user changes
Private Sub dgvExample_CellValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) _
Handles dgvExample.CellValidating
Dim results As String = String.Empty
dgvExample.CurrentCell.ErrorText = String.Empty
Select Case dgvExample.Columns(e.ColumnIndex).HeaderText
Case "Start Date", "End Date"
results = ValidateDate(e.FormattedValue)
If results = "" Then
results = ValidateDateRange(e.RowIndex)
End If
Case "Billed Amt"
dgvExample(e.ColumnIndex, e.RowIndex).Value = FormatNumber(CType(e.FormattedValue, Double), 2, TriState.False, TriState.False, TriState.False).ToString
results = ValidateBilledAmount(e.RowIndex)
End Select
dgvExample.CurrentCell.ErrorText = results
End Sub
'handles dgv dataentry events
Private Sub dgvExample_EditingControlShowing(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) _
Handles dgvExample.EditingControlShowing
'Change Case to upper case for all textboxes
Dim editingControl As TextBox = TryCast(e.Control, TextBox)
If editingControl IsNot Nothing Then
editingControl.CharacterCasing = CharacterCasing.Upper
End If
End Sub
'FUNCTIONS called in above
'check dates not old or in future
Private Function ValidateDate(ByVal dte As String) As String
Dim errorMessage As String = ""
If CType(dte, Date) > Now Then
errorMessage = "DATE cannot be in the future"
Return errorMessage
End If
If CType(dte, Date) <= Now.Date.AddYears(-1) Then
errorMessage = "WARNING: DATE cannot be older than 1 year"
Return errorMessage
End If
Return errorMessage
End Function
'Checks that start date is less than end date
Private Function ValidateDateRange(ByVal rowIndex As Integer) As String
Dim errorMessage As String = ""
If CType(dgvExample.Rows(rowIndex).Cells(1).Value, Date) > _
CType(dgvExample.Rows(rowIndex).Cells(2).Value, Date) Then
errorMessage = "START DATE cannot be after END DATE"
End If
Return errorMessage
End Function
'validates billed amount is currency and in range
Private Function ValidateBilledAmount(ByVal rowIndex As Integer) As String
Dim errorMessage As String = ""
Dim billedAmt = dgvExample.Rows(rowIndex).Cells(11).Value
If Not String.IsNullOrEmpty(billedAmt) Then
If IsNumeric(billedAmt) Then
If CType(billedAmt, Decimal) > 0 Then
If billedAmt > 100000.0 Then
errorMessage = "BILLED AMOUNT must not exceed $100,000"
End If
Else
errorMessage = "BILLED AMOUNT must be greater than $0"
End If
Else
errorMessage = "BILLED AMOUNT must be numeric"
End If
End If
If errorMessage = "" Then
CalculateNewTotal()
End If
Return errorMessage
End Function
I just tested this and in order to get the ValidateChildren to work, you need to programmatically set the event handler using AddHandler.
Private Sub DataRepeater1_DrawItem(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs) _ Handles DataRepeater1.DrawItem
AddHandler e.DataRepeaterItem.Controls.Item("ctlDateTimePicker").Validated, AddressOf dtpStartingServiceDate_Validating ' Validating DatePicker
AddHandler e.DataRepeaterItem.Controls.Item("ctlComboBox").Validated, AddressOf cboUnitType_Validating
End Sub
Once the Validated event handler is initialized, you can then call 'Me.ValidateChildren()' to cause the validation to run. I don't know if it's good or bad for your situation but the validation event will execute whenever the control's value is changed.
Let me know if that works.

Gridviews and DropdownLists

Is it possible to change the data source of a dropdown list in a gridview from another dropdown list selected index changed method in the same gridview?
for example I have a dropdown that needs to change its contents depending on what is chosen in the previous cell of the gridview, which is also a dropdown list.
Any Help would be much appreciated
Thanks
Instead of changing the DataSource when the 1st DropDownList.SelectedIndex changes, you could set the DataSource of the 2nd DropDownList when it is being edited.
An example of how this can be achieved can be found here.
In this article, the author hooks to the EditingControlShowing event in order to change the type of the ComboBox. This can be easily modified to change the DataSource instead:
Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
' make sure we are editing the 2nd ComboBox:'
Dim comboBoxColumn2 As DataGridViewComboBoxColumn = DataGridView1.Columns(2)
If (DataGridView1.CurrentCellAddress.X = comboBoxColumn2.DisplayIndex) Then
'here you retrieve the value of the 1st ComboBox:'
Dim comboBox1Value As object = DataGridView1.SelectedRow... 'fill with whatever is needed'
Dim cb As ComboBox = e.Control
If (cb IsNot Nothing) Then
cb.DataSource = Nothing 'maybe not needed, I'm not sure
cb.DataSource = 'here, set the data source based on the value of ComboBox1'
End If
End If
End Sub
Here is another way how I would do this, by example: Two columns (Types, Days), if the user drops-down and chooses 'week', a second combo populates with week days, otherwise, weekends.
For the purpose of this example, add a grid (DataGridView1) with two ComboBoxCell columns and let the first column have these items: week, weekend.
This class will be our data source:
Class WeekDataItem
Sub New(ByVal id As Integer, ByVal name As String)
Me.ID = id
Me.Name = name
End Sub
Public Property ID() As Integer
Get
Return _ID
End Get
Set(ByVal value As Integer)
_ID = value
End Set
End Property
Private _ID As Integer
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Private _Name As String
End Class
This function will return our data source, based on the key which can be 'week' or 'weekend':
Function getWeekDataSource(ByVal key As String) As List(Of WeekDataItem)
getWeekDataSource = New List(Of WeekDataItem)
If (key = "week") Then
getWeekDataSource.Add(New WeekDataItem(1, "monday"))
getWeekDataSource.Add(New WeekDataItem(2, "tuesday"))
getWeekDataSource.Add(New WeekDataItem(3, "wednesday"))
getWeekDataSource.Add(New WeekDataItem(4, "thrusday"))
getWeekDataSource.Add(New WeekDataItem(5, "friday"))
ElseIf (key = "weekend") Then
getWeekDataSource.Add(New WeekDataItem(6, "caturday"))
getWeekDataSource.Add(New WeekDataItem(7, "sunday"))
End If
End Function
And lastly, this event will fire when the Type combo value changes, and assign the appropriate data source to our days combo:
Private Sub DataGridView1_CellValueChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
' if the type dropdown value changed
If (e.ColumnIndex = clmTypes.Index) Then
' set the week dropdown data source for the current row
If Not IsNothing(DataGridView1.CurrentRow) Then
' get the combobox cell we want to change
Dim comboCell As DataGridViewComboBoxCell
comboCell = CType(DataGridView1.CurrentRow.Cells(clmDays.Index), DataGridViewComboBoxCell)
' assign it's new data source
comboCell.DataSource = getWeekDataSource(CStr(DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value))
' update the data source members so it displays info properly
comboCell.DisplayMember = "Name"
comboCell.ValueMember = "ID"
End If
End If
End Sub
Note that this event fires after the cell is validated, ie once you tab off the cell.
It is totally possible. How are populating your dropdownlists ? If all the data is dynamic then you will have to rebuild the entire grid everytime you change the dropdownlist selected item.
If I am not wrong , you are trying to apply Filter mechanism. Are you ? Another way I have done in the past is to build my data source for DropDownList from the rows of GridView. Think about the data that you already have on the screen. Once you are in PreRender Function you can bind needed data in your dropdownlist, this way you will cut out load.