Select three fields in SQL datasource but only display two in datalist

How would I do this?  I have to select the First and last name to show up in the datalist, but I also need to select the key because I am updating another column in the selected row.  How would I display only the first and last name?

0
igavemybest
4/2/2008 12:36:47 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

7 Replies
765 Views

Similar Articles

[PageSpeed] 42

You can edit the html in the aspx page and remove that item from the templates.


Bruce


Please remember to click "Mark as Answer" on the posts that helped solve your issue.
0
BHendry
4/2/2008 12:51:25 AM

The problem is the template doesnt know the name yet because the sql select is selecting from a "' + table + '" so that wouldnt work.  Sorry I forgot to menton that.

0
igavemybest
4/2/2008 12:57:06 AM

If you post the code and codebehind that loads your datalist I will take a look.


Bruce


Please remember to click "Mark as Answer" on the posts that helped solve your issue.
0
BHendry
4/2/2008 1:09:36 AM
<%@ Page Language="VB" masterpagefile="~/MasterPage.master" AutoEventWireup="false" CodeFile="schedulecourses.aspx.vb" Inherits="schedulecourses" %> 

<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="radG" %>

<asp:Content ID="Content2" ContentPlaceHolderID=ContentPlaceHolder1 runat=server>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>">

</asp:SqlDataSource>

<asp:DataList ID="DataList1" runat="server" BackColor="White" BorderColor="#3366CC"

BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource1"

GridLines="Both">

<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />

<ItemStyle BackColor="White" ForeColor="#003399" />

<SelectedItemStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />

<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />

</asp:DataList>

</asp:Content>

________________VB_______________

Imports System.Data

Imports System.Data.Common

Imports System.Data.SqlClient

Imports System.Linq

Partial Class schedulecourses

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

'LINQ START

Dim user_currentUserID = Page.User.Identity.Name.ToString()

Dim db As New DataClassesDataContext

Dim CompanyKey

CompanyKey = (From p In db.Company_Memberships Where p.EmpUserID = user_currentUserID Select p.CompanyKeys).First.ToString()

'LINQ END

SqlDataSource1.SelectCommand = "SELECT UserID, First, Last, Division FROM [" & CompanyKey & "]"

 

'SqlDataSource1.DeleteCommand =

'SqlDataSource1.InsertCommand =

'SqlDataSource1.UpdateCommand =

End Sub

End Class

0
igavemybest
4/2/2008 1:38:50 AM

Anyone else have any suggestions?

0
igavemybest
4/2/2008 2:26:25 AM

I'm not seeing where you are referencing an ItemTemplate. Are you using a dynamic template? From the code you posted I don't see how your DataList1 would even render. Regardless, your table is dynamic but the UserID appears static so you should be able to access it.


Bruce


Please remember to click "Mark as Answer" on the posts that helped solve your issue.
0
BHendry
4/2/2008 4:00:51 AM

Thanks, I am just going to try something easier that wont cause any trouble for me!

0
igavemybest
4/2/2008 4:13:35 AM
Reply:

Similar Artilces:

Simple display image from Sql Server with a datalist and datasource control
Hello and thanks for your help in advance as I am struggling with something fairly easy but as a novice I am probably nor understanding how things work. I am trying to retrieve an image that I can succesfully upload in a SqlServer database in an asp.net page, I have read many many tutorials but I have not found something that matches with what this: I simply have a web form with a correcly configured sqlDataSource control and a datalist on which I have used an image control to bind to the image BLOB field in the database table, clearly this not work... I understand that the image control l...

How to display the more than one row with items and buttons in gridview control. when i select three items at same time from categories(Fruits, Apples, Gifts). The selected items are displayed in g
Hi,when i select three items at same time from categories(Fruits, Apples, Gifts). The selected items are displayed in gridview.Here i would like to change this way "when i click more than one category at same time. it should be display selected item and button."For example: if i have to select Fruits, Apples from categories.  it should be display like 1st "row have Fruits and In 2nd row have Apples and button" in gridview.the button have some event.How can i do it? Please can anyone answer me.With kind requestThanks your query is very raw..can u details it out...Pl...

testing two three two three two two
Test ...

Display Selected fields from two tables
Here's the challange: I have a "orders" datatable with data I'd like to be able to update. I have another related "clients" datatable in the dataset (related by "client id"). I'd like to be able to display the orders in a datagrid and include a "client name" column (from the "clients" datatable). I don't believe that I can use a mixed table query - and still be able to update the data. Am I missing something obvious here? TIA - Geoff Yes you are missing something. Your select query isn't tied to your update or insert queries. ...

Display RTF on Datawindow with SQL Select datasource
Does anyone have a solution for displaying RTF on SQL select datawindows? I need to display a signature (RTF file, stored as a blob in SQL Anywhere 5.5.04) on a report. During testing, I was using SelectBlob and PasteRTF to a RTF datawindow. Little did I know, you cannot use a RTF report as a nested report. I tried using a database blob object linked to the blob field. I used wordpad and word for the OLE class. However, nothing is displayed upon retrieval. Double clicking the OLE blob field opens a blank Word doc. I even tried saving the RTF datawindow as a WMF file, hoping to use WMF w...

Automatically caculate two values that are entered into two different fields and displayed in a Third Field
 Hello, I use the following code in a GridView page to caculate two values that are entered into two different fields and the result is displayed in the TotalHoursPerUnit field.  I am trying to convert the Code Behind The Page to work under the Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBound, but no luck.  Please suggest a way to modify the statements to work with text boxes in a FormView control. Thank you in advance, ASPX Page <script language ="javascript"  type="text/javascript&qu...

DataList Control, Displaying some part of row field from DataBase
Hi, I've DataList Control in my web page, I'm retrieving Data from Database. I'm able to retrieve successfully. Here what I need is: There is a News Column in NewsTable, this News column has 10 lines of Data, when we show in the web page. I want to display only 3 lines of data from this column and beside this there should be "More News"  should appear. When the users clicks it will redirect to another page with full 10 lines News.I hope you understand... Thanks in adavance  Asghar Ali Mohammed http://www.aliwebdev.com(Web Designer and Develo...

Display Selected Dates in .NET Calendar Control..HELP!
Okay, I am a newbie to ASP.net, so hang with me here! I need to create a data-driven calendar using the ASP.net calendar control and an existing Oracle database. I followed the MSDN "How to" ( http://msdn2.microsoft.com/en-us/library/ms228044(VS.80).aspx ) utilizing the SQL database without a problem; however, once I recode to use my Oracle connection string and database, I receive an ArgumentException that says "Keyword not supported: 'Unicode'." at the connection string variable. I have imported the System.Data. & System.Data.SqlClient namespaces, but now I'm wonder...

Display SQL field wtih Label Web Control
Hello, I know this is probably a simple task, but I can't seem to figure out how to do it. I want to display a field from an SQL database as a label. For example: Customer Name: <INFO FROM DATABASE> Can anyone give me hand? Thanks! Jason To display date in case you are using DataSet ds.Tables(0).Rows(0)("CustomerName").ToString In case of DataReader dr("CustomerName").ToString Sushila Bowalekar PatelVisual ASP/ASP.NET MVPhttp://weblogs.asp.net/sushilasb Assume your <INFO FROM DATABASE> label is named lblCustomerNameDB ...

Binding a Third-Party Control to a SQL Datasource Field
VWD 2008 Express.  Visual Basic. I am trying to use an HTML editor control (it called Cute Editor from CuteSoft http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx) in a formview that is bound to an SQL datasource.  Unfortunately, there is neither a wizard nor a property in the editor control which easily allows me to bind its Text property to one of my SQL datasource's fields.  The editor (its called the Cute Editor) property I wish to bind is Editor1.Text.  The field in the SQL datasource I wish to (two-way) bind to is called strBio.  Can anyone sugge...

Displaying related fields with an SQL database and ADO.NET
Okay, so I know how to display a singular table from an SQL databse into a datagrid, but I was never shown how to display related fields into one table. Here is the problem: I need to display student information for an online college solution. The information I need to display is First Name, Last Name, and some information from the course they are currently taking. Now - the student information is in a Student table and the course information is in (you guessed it) the Course table. The student table contains a foreign key, the courseID, which is obviously the key in the course table....

Selecting from two tables with different data
Hello!I have two tables:Pressreleases:| Pressrelease_ID | PressDate | FilePath | Title |PressLinks:| PressLink_ID | PressLinkDate | PressLinkUrl | PressText |I would like to select the the TOP 3 with the most recent dates from either Pressreleases or PressLinks, and present them in a DataList. How do I do that? Selecting from one table is no problem:SELECT TOP 3 Pressreleases.PressDate, Pressreleases.Filepath, PressReleases.Title FROM Pressreleases ORDER BY PressDate DESCHow do I select from both tables and rename the columns to Date, Path, Text so that I can us...

Validator control causes two tabs out of a field when display = none?
The website I am building requires an alert popup box to display any errors that occur during client side validation. Here is code to reproduce the scenario: <form id="form1" runat="server">                                      <asp:TextBox ID="tb" runat="server"></asp:TextBox>  <asp:RangeValidator ID="rv" runat="server" Type="integer" ControlToValidate="tb" Display="None" Se...

select two fields into one field
hi i want to select two fields and put them into one field. for example, i want to select firstname and surname and then put them into a field called name in a new table. does anybody have any suggestions how i can do this? i want to use a 'select into' statement becasue i am gathereing fields from different tables and putting them into one  thanks You should keep them separate. You can always link them together in your SELECT statement: SELECT firstname + ' ' + surname as name FROM yourtableLimno thanks for your reply. i cant keep them seperate bec...

Web resources about - Select three fields in SQL datasource but only display two in datalist - asp.net.presentation-controls

Datasource - Wikipedia, the free encyclopedia
A DataSource object has properties that can be modified when necessary. For example, if the data source is moved to a different server, the property ...

Inverness Graham Acquires DataSource
Inverness Graham , a lower middle market private equity firm headquartered in suburban Philadelphia, has acquired DataSource , a print supply ...

SmartGlance for iPad for iPad on the iTunes App Store
Read reviews, get customer ratings, see screenshots, and learn more about SmartGlance for iPad on the App Store. Download SmartGlance for iPad ...

Chaitanya Pandit (@chaitanyapandit) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Data source - Wikipedia, the free encyclopedia
... Data source A data source is any of the following types of sources for (mostly) digitized data: a database in the Java software platform, datasource ...

2ndQuadrant - PostgreSQL expertise from specialists with a source code level understanding of RDBMS ...
PostgreSQL expertise from specialists with a source code level understanding of RDBMS PostgreSQL Planets Gabriele’s PlanetPostgreSQL Gianni’s ...

Tagged entries for CLOUD COMPUTING
Alan Williamson's output as a Java Champion, Blog-City Architect, BlueDragon Creator, Author, Speaker and Internet Guru

Private equity deals
... of biometric identity management systems, applications and services. www.crossmatch.com Inverness Graham Investment has acquired DataSource ...

C# C Sharp and Tutorials on C# Friends.com
Learn the c# langauge to build web applications using our online tutorials with live demos. Participate in our forums and learn from others. ...

JavaScript UI Library, Ajax Components & HTML5 Framework - DHTMLX
DHTMLX offers a rich JavaScript library, UI components & HTML5 mobile framework. Build impressive web apps for both desktop and mobile devices. ...

Resources last updated: 12/9/2015 8:05:44 PM