473,995 Members | 14,128 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP??? DataGrid

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.DataI tem, "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:TemplateCo lumn HeaderText="">
Line 40: <ItemTemplate >
Line 41: <asp:HyperLin k 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("cont acts").NewRow
dr(" ") = "<img src='../images/user.gif'>"

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

If res.Properties. Contains("physi calDeliveryOffi ceName") Then
dr("Dept.") =
CStr(res.Proper ties("physicalD eliveryOfficeNa me")(0))
Else
dr("Dept.") = ""
End If

If res.Properties. Contains("telep honeNumber") Then
Dim TeleNumber As String =
CStr(res.Proper ties("telephone Number")(0))
dr("Ext") = "#" & Right(TeleNumbe r, Len(TeleNumber) -
InStr(TeleNumbe r, "1"))
Else
dr("Ext") = ""
End If

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

ds.Tables("cont acts").Rows.Add (dr)

Next
' Binds Contact data from Active Directory to DataGrid
DataGrid1.DataS ource = ds.Tables("cont acts")
DataGrid1.DataB ind()

Nov 19 '05 #1
1 1072
Hi Tim,

You can use HyperLinkColumn like follows

<asp:HyperLinkC olumn HeaderText="Giv en Name"
DataNavigateUrl Field="givenNam e"
DataNavigateUrl FormatString="m yUrl.aspx?id={0 }" Text="<img
src='../images/user.gif' border='0'>" Target="_blank" >
<img src="../images/user.gif" border="0">
</asp:HyperLinkCo lumn>

HTH

Elton Wang
el********@hotm ail.com

"Tim::.." wrote:
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.DataI tem, "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:TemplateCo lumn HeaderText="">
Line 40: <ItemTemplate >
Line 41: <asp:HyperLin k 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("cont acts").NewRow
dr(" ") = "<img src='../images/user.gif'>"

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

If res.Properties. Contains("physi calDeliveryOffi ceName") Then
dr("Dept.") =
CStr(res.Proper ties("physicalD eliveryOfficeNa me")(0))
Else
dr("Dept.") = ""
End If

If res.Properties. Contains("telep honeNumber") Then
Dim TeleNumber As String =
CStr(res.Proper ties("telephone Number")(0))
dr("Ext") = "#" & Right(TeleNumbe r, Len(TeleNumber) -
InStr(TeleNumbe r, "1"))
Else
dr("Ext") = ""
End If

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

ds.Tables("cont acts").Rows.Add (dr)

Next
' Binds Contact data from Active Directory to DataGrid
DataGrid1.DataS ource = ds.Tables("cont acts")
DataGrid1.DataB ind()

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2457
by: Bruce Pullum | last post by:
I have a datagrid that I am using a DataView with. All works great for the sorting of the columns. However, after I sort the column, and then try and select a data row to edit, the row selected represents the indes of the actual DataGrid and not the DataView. For example.. Lets say I have 4 rows of data.. In the 4 rows I have an Appt Num of 1,2,3,4... Each representing a data row... I sort DESC so the rows display 4,3,2,1... If I...
2
5154
by: Anita C | last post by:
Hi, How do I associate or map a specific column in a datatable to a particular element present in an xml document - to read into a datatable as well as write from the datatable to the xml element? Also, how can I associate all the attributes and their values of a particular element to the Name & Value columns of a datatable - to read into a datatable as well as write from the datatable to the xml element? Any help will be greatly...
8
3140
by: pei_world | last post by:
Hi, there; I have a problem with my datagrid control. I declared it in one of my form, set with DataGridTalbeStyle as well, and when I click on button, I would like to retrive Data from Database and bind these data to my datagrid in the form, when I click the button first time, it work fine. but when I click the second button. it report belowing error, I guess it is because it already set up the column name at first time, so cann't do...
0
3658
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a datagrid on the left side that lists names and perhaps a couple of other key fields. The user can click on a record in the datagrid, which should automatically pull up details on that record in the various text boxes and other controls on the right...
1
1529
by: Michael Gorbach | last post by:
Iv got a StatisticsContainer object that contains an arraylist of objects of different types, all inherited from class Statistic. The statistics class has 2 string public properties, name and stringValue. The classes that inherit from it use those two properties, plus several properties of their own of types double and vector. I need to display this StatisticsContainer class on a datagrid, but I'm having problems because each of the...
14
1863
by: Brett Sinclair | last post by:
Hello everybody I'm still on the learning curve here...and from what I read, I created inherited datagrid class so I could have icons, combobox...etc in the columns of my datagrid. The grid will be used to populate information coming from a Webservice. (No datasets - No datareaders). So, I do not know see how to use the "datasource".
6
4703
by: Coleen | last post by:
Hi All :-) Thanks for all of your help Cor :-) I can not get the code you sent me to work in my application. I'm using an aspx datagrid in a web form. I'm getting the following error message when I try this code: "Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier." Dim dr2 As DataRow = dt_stat_report_3b.NewRow Dim sum As Double =...
2
1332
by: Brad Shook | last post by:
First of all thinks to Cor Ligthert for helping me with this last week. If you wild like to read Cor's comments please refer to the posting from 10/14/2004 and 8:48AM "Help with Advanced Datagrid" I am trying to bind one column of a datagrid to a seperate textbox and the rest of the fields to a datagrid. the comments are too large to fit in a datagrid so I created a textbox below the datagrid and need it to hold the data for the...
3
2533
by: Datatable Dataset Datagrid help | last post by:
Hi I am somewhat confused, I am new at VB.net I use XML data, I have a datagrid, I created a datatable so that I can create a custom format like true is this graphic false is this graphic and others. One of the custom format is as follows: dsmessages_dt.Columns.Add("Image", GetType(Image)) I had a problem of when I used a checkbox in the grid that was bound to the datatable that it would not update my dataset. So I created another...
4
2152
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a Delete button on the end of each row. I am unable to gain access to the event when the button is clicked. I don't fully understand how the click gets connected to the C# code,
0
10424
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10239
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11941
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11005
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8563
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6674
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4841
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.