Datagrid problem...

G

Guest

Hi...

Can someone please tell me how I get the following values from the datatable
below into a datagrid??? I want to use template columns so I can minipulate
the data but don't know how to get the values into the templated columns...

I tried...

Container.DataItem, "givenName"

but get the following error...

Compiler Error Message: BC30519: Overload resolution failed because no
accessible 'ToString' can be called without a narrowing conversion:

Source Error:

Line 39: <asp:TemplateColumn HeaderText="">
Line 40: <ItemTemplate>
Line 41: <asp:HyperLink Runat =server NavigateUrl ='<%#Container.DataItem,
"givenName"%>' ID="urlImage">
Line 42: <img src="../images/user.gif" border="0">
Line 43: </asp:HyperLink>


Thanks for any help!

....CODE...
For Each res As SearchResult In src.FindAll


Dim dr As DataRow = ds.Tables("contacts").NewRow
dr(" ") = "<img src='../images/user.gif'>"

If res.Properties.Contains("sn") And
res.Properties.Contains("givenName") And res.Properties.Contains("Initials")
Then
dr("Name") = CStr(res.Properties("givenName")(0)) & ", " &
CStr(res.Properties("sn")(0)) & " " & CStr(res.Properties("Initials")(0))
Else
dr("Name") = ""
End If

If res.Properties.Contains("physicalDeliveryOfficeName") Then
dr("Dept.") =
CStr(res.Properties("physicalDeliveryOfficeName")(0))
Else
dr("Dept.") = ""
End If

If res.Properties.Contains("telephoneNumber") Then
Dim TeleNumber As String =
CStr(res.Properties("telephoneNumber")(0))
dr("Ext") = "#" & Right(TeleNumber, Len(TeleNumber) -
InStr(TeleNumber, "1"))
Else
dr("Ext") = ""
End If

If res.Properties.Contains("mail") Then
dr("Email") = CStr(res.Properties("mail")(0))
Else
dr("Email") = ""
End If

ds.Tables("contacts").Rows.Add(dr)

Next
' Binds Contact data from Active Directory to DataGrid
DataGrid1.DataSource = ds.Tables("contacts")
DataGrid1.DataBind()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top