You need to sign in to do that
Don't have an account?

SalesForce Data To DataGrid....Please advise
Instead of getting the values for two columns (Id and CreatedDate) I am getting only 1 column called “length” with the numbers of the length.
What I am doing wron here??
Private Function GetData() As Boolean
Cursor = Cursors.WaitCursor
Dim qr As sForce.QueryResult
Dim queryString As String
Dim list As System.Collections.ArrayList = New System.Collections.ArrayList
queryString = "select Id, CreatedDate from TH_Revenue_Totals__c"
Try
qr = binding.query(queryString)
If Not qr.records Is Nothing Then
Dim i As Integer
For i = 0 To qr.records.Length - 1
Dim rs As sForce.TH_Revenue_Totals__c
rs = qr.records(i)
list.Add(rs.Id.ToString)
list.Add(rs.CreatedDate.ToString)
Next
DataGrid1.DataSource = list
GetData = True
Else
GetData = False
End If
Return GetData
Catch ex As Exception
lblStatus.Text = ex.Message
Finally
Cursor = Cursors.Default
End Try
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Call GetData()
End Sub
Hi Ahlomon ,
I have done the same in C#.Use a DataTable and in the For loop create an object of the type from which you want to get the information and add it to the datatable.Then add the DataTable to the Dataset and bind this dataset to the grid.I will paste the sample code here.
qr = binding.query("select id,firstname,lastname from contact where firstname=" + "'" + dr[1] + "'");
ArrayList records = new ArrayList();
DataTable dt = new DataTable("contact");
dt.Columns.Add(new DataColumn("Id"));
dt.Columns.Add(new DataColumn("FirstName"));
dt.Columns.Add(new DataColumn("LastName"));
bool exitloop = false;
while (!exitloop)
{
for (int i = 0; i <= qr.records.Length-1; i++)
{
SForce.Contact obj = (SForce.Contact)qr.records[i];
dt.Rows.Add(new object[] { obj.Id, obj.FirstName, obj.LastName });
}
if (qr.done)
{
exitloop = true;
}
else
{
qr = binding.queryMore(qr.queryLocator);
}
}
ds.Tables.Add(dt);
contact.DataSource = ds;
contact.DataBind();
Bharathi
Hi Bharathi,
Thanks you very much!!!!!!
IT WORKED!!!!!
I am getting 'The name 'binding' does not exist in the current context ' error while using your code. Coud you please explain more about binding here?
Thanks in advance