Why can't I do this????

G

Guest

I keep getting the following error when trying to do the following!

'DataBinding' is not an event of 'System.Web.UI.WebControls.HyperLinkColumn'.

How do I get the value Name into the DataNavigateURLField??? I would really
appritiate any advice! Thanks

<asp:hyperlinkcolumn
DataNavigateUrlField='<%#Replace(Container.DataItem.GetDirectoryEntry().Name,"CN=","")%>'
DataNavigateUrlFormatString="usrManDetails.aspx?id={0}" Text="<img border=0
src=../images/edit.gif alt=Edit Page>">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:hyperlinkcolumn>
 
G

Guest

Tim, the "canned" columns like hyperlinkcolumn and boundcolumn don't get
databound themselves. Instead, you specify just the field names from the
datasource on the datagrid. So, for DataNavigateUrlField just enter the field
name that corresponds to the {0} in your format string.

e.g. from the docs...
<Columns>
<asp:HyperLinkColumn
HeaderText="Select an Item"
DataNavigateUrlField="IntegerValue"
DataNavigateUrlFormatString="detailspage.aspx?id={0}"
DataTextField="PriceValue"
DataTextFormatString="{0:c}"
Target="_blank"/>
</Columns>

Or, skip the hyperlinkcolumn, create your own itemtemplate, and add your own
asp:hyperlink that you can databind to (I find this way easier and more
flexible than the canned choices).

Bill
 
G

Guest

Thanks Bill,

I have no problem when my datasource is a database or something similar it
is just when I use DirectoryServices

For some reason I cant get it to work...

Here is my databind!

Would really appritiate any help anyone can provide!

Thanks

...CODE
Sub GetUserADInfo()
Dim strUserName As String
Dim strADPath As String

strUserName = "netadmin" 'HttpContext.Current.User.Identity.Name
strADPath = "netdomain.usembassy.dk"


Dim Entry As DirectoryEntry = New DirectoryEntry("LDAP://" &
strADPath, "netadmin", "N3753rv3r0!")
' Create a DirectorySearcher object.
Dim mySearcher As New DirectorySearcher(Entry)
' Use the FindOne method to find the object, which in this case, is
the user
' indicated by User Name and assign it to a SearchResult.
mySearcher.Filter = ("(&(objectCategory=person)(objectClass=user))")
'Dim MySearchResult As SearchResult = mySearcher.FindOne
Dim results As SearchResultCollection
results = mySearcher.FindAll()
dgADUserInfo.DataSource = results
dgADUserInfo.DataBind()

End Sub
 
G

Guest

Regardless of datasource, you still can't do the databind (<%#...%>) in a
hyperlinkcolumn. DataNavigateUrlField needs the name of a public property of
the dataitem. I don't do much with AD, but in your case looks like each
dataitem is of type SearchResult, so DataNavigateUrlField should be a
property of that, e.g. "FileName", etc., and the framework will use
reflection to go get that value.

Also, this is among the reasons I gravitate toward the code-behind and
ItemDataBound--getting this straight in the html w/out intellisense, etc. is
pretty tedious.

Have fun.

Bill
 

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

Top