customunboundcolumndata event not firing in DEVExpress gridview - events

I have been struggling with the below code snippet. "CustomUnboundColumnData" event is not firing.
Protected Sub gvAlertReport_CustomUnboundColumnData(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs)
If e.Column.FieldName = "Active" Then
Dim val As String = e.Value
Dim img As New ImageButton()
Select Case val
Case "False"
img.ImageUrl = "Images/gray_bell.png"
img.Attributes.Add("", "")
Case "True"
img.ImageUrl = "Images/red_bell.png"
img.Attributes.Add("", "")
Case Else
End Select
End If
End Sub
Thanks in Advance..

The CustomUnboundColumnData event is only triggered if there is a column in the ASPxGridView which is designed as an Unbound Column. To learn how this can be done, please refer to the Unbound Columns Overview topic. Also, please make certain that the gvAlertReport_CustomUnboundColumnData is the actual event handler for the ASPxGridView.

Related

Retrieving Only Selected Field Using LINQ

i have a problems regarding on filtering my code in retrieving companyName from its table..when i query here is the result .. please see my code
Sub call_customers(ByVal dgv_customers As DataGridView)
Dim customers_name = From cust In dbcon.Customers _
Select cust.CustomerID, cust.CompanyName Order By CompanyName Ascending
dgv_customers.DataSource = customers_name
End Sub
the display is CustomerID and CompanyName.. yeah its true.. no problem with the code..
and if i only select cust.companyname the result is this ....like this code
Sub call_customers(ByVal dgv_customers As DataGridView)
Dim customers_name = From cust In dbcon.Customers _
Select cust.CompanyName
dgv_customers.DataSource = customers_name
End Sub
the output is this...
enter image description here
no display and it says length.. why? newbie in LINQ sir ..
please help..
Originally, you were giving the grid an object, and it was displaying each of the properties of that object.
Now that you are giving it a string, it is doing the same thing, but now, the only property on the string is the length,

vb6 textbox show false message sdafjklasdf

textbox show "false" when I click datalist .
please help me .
stuck here .
Private Sub DataList1_Click()
Txtnama.Text = DataList1.ListField = "nama"
End Sub
please help me guys .
You can't cascade an assignment statement. Your statement is performing a comparison: Datalist1.ListField = "nama", then assigning the results of that comparison (True or False) to the textbox.
Perhaps you want to be assigning the same value to the textbox and list field? If so, then you should use this:
txtnama.Text = "nama"
DataList1.ListField = "nama"
If that's not what you are trying to do, then you need to provide a better, more complete explanation of your requirements.

Highlight a Telerik RadGrid row based on error

I would like to highlight a row from my RadGrid base on a logic row error (not database related).
I'm using Telerik Ajax .net RadGrid With VB.NET
If ok > 2000 Then
Dim errorRowOrderNumber = ok / 1000
'Get the RadGrid row error index
myErrorRow.Drawing.Color.Red
myErrorRow.Drawing.Color.White
End If
Use this if you can identify the error condition on item data bound event:
Protected Sub grid_ItemDataBound(sender As Object, e As GridItemEventArgs)
Try
If TypeOf e.Item Is GridDataItem Then
Dim dataRow = TryCast(e.Item, GridDataItem)
' Replace with validation logic
If True Then
dataRow.BackColor = Drawing.Color.Gray
dataRow.ForeColor = Drawing.Color.White
dataRow.ToolTip = "Some information about this error."
End If
End If
Catch ex As Exception
' handle exception
End Try
End Sub
In any other grid command event you can get a reference to the same GridDataItem object.
If you can't use a grid event try looking into client-side options.

Display newly created record in Formview

I have this form on VS2012 with asp.net. First I do search for the patron, then go to verify information for that patron. This patron information is displayed in ItemTemplate(ReadOnly). If that is not the patron they are looking for then they can add a new patron with "New button" (asp.net code). I am able to get the id of the new Patron(which is PK). However I am not able to display this newly created record on the form after inserting. It still displays the record which was on display. Since this a formview I did not enable "Paging".
Is it possible to call the pageload event from datasource_inserted event? Then I can pass the new patron ID for display. I declared this ID as global variable?
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim lvPatronID As String
lvPatronID = Request.QueryString("value1")
If lvPatronID = "" Then
frmPatronView.ChangeMode(FormViewMode.Insert)
Else
frmPatronView.ChangeMode(FormViewMode.ReadOnly)
GvPatronID = lvPatronID
lblPatronID.Text = GvPatronID
End If
Protected Sub PatronDS_Inserted(sender As Object, e As SqlDataSourceStatusEventArgs) Handles PatronDS.Inserted
NewID = e.Command.Parameters("#PatronID").Value.ToString
GvPatronID = NewID
End Sub
Well I answered part of my own question. The following change to the Inserted event will let me view the newly inserted data. I have another button to add new record in the emptytemplate of the search form. This is why I am changing the mode to insert as the default mode is readonly. This will let me insert the data but after inserting it doesn't display the form at all. Not sure why Inserted event is not kicking in properly.
Protected Sub PatronDS_Inserted(sender As Object, e As SqlDataSourceStatusEventArgs) Handles PatronDS.Inserted
Dim NewID As String = Nothing
Try
NewID = e.Command.Parameters("#PatronID").Value.ToString
PatronDS.SelectCommand = "SELECT * FROM tblPatron WHERE PatronID='" & NewID & "'"
lblPatronID.Text = NewID.Trim()
frmPatronView.DataBind()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

setting initial value in combobox in vb

I got a combobox that is populated from a access database. How can I add an item say "all" to the list got from the database and then display it as the first value
After binding it. You can quiet easy do this:
cb.Items.Insert(0,"ALL")
Liked said in the comment. Do this:
Private Sub fview_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
Timer1.Interval = 1000
cenNum.DropDownStyle = ComboBoxStyle.DropDownList
cenNum.Items.Insert(0, "All") 'adding all to combo
fData() 'function populating the combo from database
cenNum.SelectedIndex=0 'The new line
end sub
You could try changing the record source of the combox box to
SELECT "All" AS Author_name FROM Author
UNION SELECT Author_name FROM Author
for example

Resources