I am setting a datalist which looks like this:
And I have table like this:
+-------------------+
|---ID----|---NAME--|
+-------------------+
|---101---|---CNN---|
|---102---|---BBM---|
+-------------------+
On the datalist I am using ID for listfield. I want show the name directly in the textbox when I choose ID list from listfield.
e.g. : i choose ID 101 in datalist then show "CNN" in textboxname
Private Sub DataList1_Click()
Txtnama.Text = DataList1.ListField = "nama"
End Sub
Problem: the textbox just shows "false".
How do I fix this code.
please help me
thanks
The problem is in the line:
Txtnama.Text = DataList1.ListField = "nama"
The right hand side of this assignment is the expression
DataList1.ListField = "nama"
which is a boolean expression. So the value of the .Text property is set to that boolean value.
Probably what you actually want to do is this:
Txtnama.Text = DataList1.ListField("nama")
so that you select only the nama value from the DataList object.
Related
I am trying to update/Insert Contact Entity. While simple text fields are saving, having difficulties updating OptionSet. For ex. new_gender field is an option set (Male/Female).
contact["new_gender"] = new OptionSetValue(1); //Does not work
contact["new_gender"] = 1; //Does not work
Error says:
"new_gender should have the Integer value of Enum. Please supply it in the format - <entitysetname>(<attributename>=100000000)"
Any help is appreciated!!
Custom OptionSets have a prefix named Option Value Prefix. I guess in you case it's "10000".
Try it this way:
contact["new_gender"] = new OptionSetValue(100000001);
You can define an Enum something like
public enum Gender
{
Male = 10000001,
Female = 10000002
}
and set the attribute of gender
contact["new_gender"] = new OptionSetValue((int)Gender.Male);
also, you can get the gender value like this;
int value = ((OptionSetValue)contact[new_gender]).Value;
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,
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.
I want to filter list as below. I have a class & I want to filter values from that are in my filter string. I have achieved my result by a for loop but need a way without for loop.
Public Class WorkStationDetails<br><br>
Property CountryId As Integer<br>
Property CountryName As String<br>
Property TotalWrkStn As Integer<br>
Property ExistingWrkStn As Integer<br>
Property RemainingWrkStn As Integer<br><br>
End Class
Dim WrkStnDtl As List(Of WorkStationDetails)
Dim FilterWrkStnDtl As List(Of WorkStationDetails)
Dim Numbers As String()
Numbers = "1,5,6,2,9".Split(",")
For i As Integer = 0 To Numbers.Length - 1
FilterWrkStnDtl.AddRange(WrkStnDtl.FindAll(Function(p) (p.CountryId = Numbers(i))))
Next
Note: I want to achieve it like subquery in sql server.
I think you want something like this"
var numbers = "1,5,6,2,9".Split(',');
var selected = WrkStnDtl.Where(w => numbers.Contains(w.CountryId)).ToList();
I have this query below and I want to show items that sold depending on sales_id without repeat the old ids. And another question how to make a combo box data grid view:
Private Sub filldatagrid()
Dim myTableName As String
myTableName = txtid.Text
winclass.filldatagrid(DataGridView1, "select inventory.inv_name,sales_data.sales_id,sales_data.quantity,sales_data.sum_total from sales_data,inventory where sales_data.inv_id=inventory.inv_id ")
DataGridView1.Columns(0).HeaderText = "ID"
DataGridView1.Columns(0).Visible = True
DataGridView1.Columns(1).HeaderText = "name"
DataGridView1.Columns(1).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
End Sub