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()
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()