C# - Combining Two Fields In A DataTextField?

Nov 18, 2010

I have a dataset which I am binding to a listbox. However, I want to combine two of the fields to make up the DataTextField. Is this possible, or am I going to have to loop through the Data Rows?

lstAddressDropdown.DataSource = dsAddress;
lstAddressDropdown.DataTextField = "StreetAddress" + "Place";
lstAddressDropdown.DataBind();
lstAddressDropdown.Items.Insert(0, new ListItem("Please select"));

It's worth noting that the dataset comes back from a web service so I can't change any stored procedure to combine the columns there.

View 2 Replies


Similar Messages:

Forms Data Controls :: Multiple Fields In DropDownList DataTextField And DataValueField?

Mar 2, 2010

How to multiple fields in DropDownList DataTextField and DataValueField

[Code]....

[Code]....

View 2 Replies

SQL Server :: Combining Two Fields With A Group?

Oct 19, 2010

[Code]....

which is giving me

And i tried

select * from @jax

group by rep

and it did not group them. How would i bring the sum ly up with the sum? so it shows 1-10 cust,sum,sumly

View 1 Replies

VS 2008 Combining Two Fields For GridView Column?

Mar 30, 2010

I have a GridView with a SQLDatasource. All of the columns in the gridview are bound to a field. Now they want a column that is not a field returned but would be two of the fields combined together. How can I do this exactly? Can someone show a line of code to display this in a column?

View 8 Replies

SQL Server :: Delete Spaces Created By Combining 2 Fields?

Aug 24, 2010

My users will enter a city/station where an incident occured, and the date. The trigger below does work, but it will occasionally put spaces between the citystation and the date. I think this happens when the citystaion name is not very long, but not sure.

(ex: city____08242010)

How can I make sure that if the incidentid is going to have spaces, that sql deletes those spaces? I need the id to be space free.

ALTER
AS
TRIGGER [dbo].[tr_AddID1]
ON [dbo].[tblIncidents]
INSTEAD
OF
INSERT..........

View 2 Replies

C# - Combining Multiple Fields In C# Dynamic Data Foreign Key Display?

Sep 30, 2010

I have two tables (Person and Location) In the Dynamic Data Site, when adding Location info, I am need to choose a person from the dropdown box which is populated via a FK. That dropdown box defaults to the field in "Person" that is titled "fname" which is first name, so it looks like "Jim" or "Steve".

I'm trying to have that dropdown box display the full name of the person it references which would be combining the fields fname and lname.

Would I do this inside a Field Template? Metadata? I'm kind of stuck on this.

If I look at the FieldTemplate for ForeignKey_Edit I see this:

[code]...

and it seems like I should be able to make something similar to "PopulateListControl" and use that instead, but I have no idea where this method even resides.

View 1 Replies

DataSource Controls :: Create A Multi Column Listbox By Combining Fields In Linq Select Statement

Jan 11, 2010

I am trying to create a multi column listbox by combining fields in Linq select statement, as Let Name = Last + First. The problem is how to pad the Last column with spaces as you would in SQL using REPLICATE so when I bind the listbox to the data, it looks like two columns.

View 5 Replies

Insert Datavaluefield And DatatextField Into Db

Jun 28, 2010

I am trying to find out if there is an easier way to insert datavaluefield and datatextfied in a DDL.... I have two dropdownlist...the second ddl prepouplates based on the first one. All works now cos i have all my datavaluefield inserted. Now i was woundering if there is a way to caputure the datatextfied too so users can see it instead of seeing the ID alone. here is my code

<
ContentTemplate>
<asp:Button
ID="butAddEntity"
runat="server"
CausesValidation="False"
CommandName="Insert"
Text="Add"
OnClick="butAddEntity_Click"
/>
<asp:Button
ID="butCancel"
runat="server"
CommandName="Cancel"
Text="Return"
/>
<strong>Bank</strong>:<asp:DropDownList
ID="ddlBank"
runat="server"
AutoPostBack="True"
DataSourceID="BankCodes"
DataTextField="BankDirectory"
DataValueField="Bank_number">
</asp:DropDownList>
<strong>Account
Number:</strong>
<asp:DropDownList
ID="ddlAccount"
runat="server"
DataSourceID="RiskfactorDaily"
DataTextField="BalanceInfo"
DataValueField="NoteAccountNumber">
</asp:DropDownList>
</ContentTemplate>

And here is my datasoure and parameter

<
asp:SqlDataSource
ID="RelationShipMerge"
runat="server"
ConnectionString="<%$
ConnectionStrings:SenderoConnectionString1 %>"
ProviderName="<%$
ConnectionStrings:SenderoConnectionString1.ProviderName %>"
SelectCommand="SELECT
BankNumber, NoteAccountNumber, RecordID FROM RelationshipMerge WHERE (RecordID = @RecordID)"
InsertCommand="INSERT
INTO [Relationshipmerge] ([BankNumber], [NoteAccountNumber],[RecordID]) VALUES (@bank_number,@noteaccountnumber,@recordid)"
UpdateCommand="UPDATE
[Relationshipmerge] SET [BankNumber] = @BankNumber, [NoteAccountNumber] = @NoteAccountNumber WHERE [NoteAccountNumber] = @NoteAccountNumber"
DeleteCommand="DELETE
FROM RelationshipMerge WHERE (NoteAccountNumber=@NoteAccountNumber)"
OnSelecting="RelationShipMerge_Selecting">
<UpdateParameters>
<asp:Parameter
Name="BankNumber"
Type="Int32"
/>
<asp:Parameter
Name="NoteAccountNumber"
Type="String"
/>
<asp:Parameter
Name="recordid"
Type="Int32"
/>
</UpdateParameters>
<DeleteParameters>
<asp:Parameter
Name="NoteAccountNumber"
Type="string"
/>
<asp:Parameter
Name="RECORDID"
Type="int32"
/>
</DeleteParameters>
<InsertParameters>
<asp:Parameter
Name="bank_number"
Type="String"
/>
<asp:Parameter
Name="noteaccountnumber"
Type="String"
/>
<asp:ControlParameter
ControlID="GridView4"
Name="RecordID"
PropertyName="SelectedValue"
Type="Int32"
/>
</InsertParameters>
<SelectParameters>
<asp:ControlParameter
ControlID="GridView4"
Name="RecordID"
PropertyName="SelectedValue"
Type="Int32"
/>
</SelectParameters>
</asp:SqlDataSource>

View 4 Replies

Display Several Records In The Datatextfield In Asp Dropdownlist?

Mar 27, 2010

Is there a way to display several records in the datatextfield in a asp dropdownlist? I know the fix when populating the dropdownlist from a datagrid was to edit your SQL query but the values I am receiving are sent via an XML string. The idea would be to display a name, price, and date in the dropdown text. Currently I am getting the following error: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'MonetaryValueServiceType' While using UPSDropDown.DataTextField = "MonetaryValue" & "ServiceType" Is there a work around to do this? The only other option is to use radio buttons (which are also a nightmare).

View 1 Replies

Web Forms :: Label Display DDL's Datatextfield?

Feb 18, 2011

How do I have a label display a DDL's datatextfield?

View 1 Replies

Web Forms :: Use The DataTextField For A Label Control?

Aug 5, 2010

<asp:SqlDataSource ID="sql_Region" runat="server" ConnectionString="<%$ ConnectionStrings:Test %>" SelectCommand="SELECT Number, Name FROM table_Region WHERE Number = @Number" SelectCommandType="Text">

<asp:DropDownList ID="dd_Region" runat="server" DataSourceID="sql_Region" DataTextField="Name" DataValueField="Number" /> Ok, I have this dropdownlist and I want to use the DataTextField for a label control.

Something like this. I want to show the region as a label but I only could get the DataValueField value not DataTextField value. Does anybody knows? <asp:Label ID="label_Region" runat="server" /> <C#>

label_Region.Text = dd_Region.SelectedValue.ToString(); <--I know by doing this, I can get the DataValueField but. label_Region.Text = (DataTextField) <<--How do I get this value? I want to show the region name not the region number

View 2 Replies

C# - DropDownList: DataTextField, DataValueField - DataEnabledField?

Jun 1, 2010

I'm currently working with a control that inherits from DropDownList (it has some extra functionality that isn't really relevant to this question, but it gives me a nice place to implement the extra stuff I'm gonig to discuss).

We're using data binding, with the DataTextField and DataValueField working absolutely fine. However, I find myself in need of a similar field that will control whether or not the item is enabled. (I've already overridden the RenderContents method of the control so it properly renders non-Enabled items, since DropDownList doesn't do this by default.)

Thus I'd like to know how to override the DropDownList's data binding so it acts exactly as normal, except a further field from each DataSource item is applied to each ListItem's Enabled property.

(NB: the field I'll be binding to isn't a straight boolean, and doesn't have an explicit/implicit cast to boolean, so I'll probably be "passing" it as a string.)

View 1 Replies

Rad Combo Box Control's DataTextField And DataValueField?

Nov 23, 2010

I have used a webservice to populate a Rad Combo Box, when the page is loaded, I need the ability to display the DataTextField, based on the returned DataValueField item

View 1 Replies

Binding Dictionary To DataTextField Property Of DropDownList

Oct 29, 2010

I have a State class defined like this:

Public Class State
Public Property StateId As Integer
Public Property Name As Dictionary(Of Integer, String)
End Class

Name(x) contains the state name in different languages. I get a collection of State from the method StateManager.GetAllStates() and I want to bind this collection to a DropDownList. The problem is that I can't find how to set the DataTextField property to let's say stateList.Name(1) which is the english name of my state.

Dim stateList As StateCollection = StateManager.GetAllStates()
Me.DataSource = stateList
Me.DataValueField = "StateId"
Me.DataTextField = "Name(1).Value" <-- Problem here
Me.DataBind()

View 2 Replies

Dropdownlist Not Behaving Properly When Datavaluefield And Datatextfield Are Same?

Mar 24, 2011

I have a dropdownlist for which I am loading data from excel. Excel has 2 columns Product and Email. Data in Product column is binding to DataTextField and Email column to DataValueField. The dropdown works fine when email is different for different product but when email has same value for different product then whatever I select, on postback the selected value changes to the first item of the same email value.

Below are the sample data in Excel to show the behavior of dropdown

Example 1. (Drop down works fine for this example)

Product Email
iPad prashanth364@gmail.com
iPhone 3G prashanth364@yahoo.co.in
iPhone4 prashanth364@in.com

Example 2. (In the example below, whatever I select (iPad or iPhone 3G or iPhone4) on post back the dropdown selected value will be iPad)

Product Email
iPad prashanth364@gmail.com
iPhone 3G prashanth364@gmail.com
iPhone4 prashanth364@gmail.com

Example 3. (In the example below, when I select iPad the dropdown works fine but when I select iPhone 3G or iPhone4 on post back the dropdown selected value will be iPhone 3G. Basically, on selecting iPhone4 here, on post back it shows iPhone 3G)

Product Email
iPad prashanth364@yahoo.co.in
iPhone 3G prashanth364@gmail.com
iPhone4 prashanth364@gmail.com

Below is the function where I am loaidng the data from excel to dropdown private void ExtractFromExcelInitial()

{
// Put user code to initialize the page here
// Create connection string variable. Modify the "Data Source"
// parameter as appropriate for your environment.
string ExcelFilePath = Server.MapPath("~/ProductExcel") + "\ProductEmail.xls";
String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + ExcelFilePath + ";" +
"Extended Properties=Excel 8.0;";

[Code].....

View 1 Replies

Move DataTextField & DataValueField From Listbox1 To Listbox2?

Jul 9, 2010

I have 2 listboxes....

Listbox1 has

DataTextField="Category"
DataValueField="CategoryID"
(coming from Dropdownlist)

I want to move a Item (a Category) from listbox1 to listbox2...but how do I move this Category Plus the CategoryID to lisbox2 (CategoryID should not be visible but still be associated with Category in Listbox2)

So I want the newly added Categories to be visible in Listbox2 ..but their CategoryID's must be invisible...but still be associated with their Category....

and when I save these Categories from Listbox2 to the Database.....its should be the CategoryID's that should go into the Database.....not the actual Category

So to explain again in a different way

I want to Move a selected DataTextField & its DataValueField from Listbox1 to listbox2

then only the array of DataValueField must be saved to Database

View 3 Replies

Web Forms :: Wrap DataTextField Of A Treeview Control?

Feb 17, 2011

I have a tree view control.The text of the tree view childs is very big ,i need to wrap the text of the tree view control.How to do that.

View 2 Replies

Web Forms :: Assign A Property Of An Object As DataTextField And DataValueField?

Feb 5, 2010

I have a list <Department> say Company.Departments with object Manager and ManagerId, ManagerName as property of Manager. I would like to fill the dropdownlist with managers as below

ddlManager.DataSource = Company.Departments;
ddlManager.DataTextField = "ManagerName";
ddlManager.DataValueField = "ManagerId";

Is there a way to specify the property of an object in DataTextField or I need to copy a Manager list for the DataSource?

View 2 Replies

Forms Data Controls :: DetailsView Not Showing DataTextField?

Apr 7, 2010

I am not sure if my subject is phrased properly but here is what I am getting problems with.I have a detailsview which had about 3 dropdownlist (ddl) on it. The DDL's works fine when I insert a new record or I try to edit an existing record.But when I just want to view the data in the detailsview it displays the primary keys (DataValueFields) instead of the associated DataTextField Value.

View 6 Replies

Forms Data Controls :: DataGrid - Show The Datatextfield Of Dropdownlist?

Aug 20, 2010

in dropdownlist show the all PatientName and save the PatientID . how to show the PatientName in DataGrid.

PatientID, PatientName are Foreign Keys. In DataBase on Save the the PatientID my requiredment is PatientName show in DataGrid based on PatientID.

View 1 Replies

Web Forms :: Dropdownlist DataBind Using Strongly Typed Property For DataTextField?

Aug 13, 2010

I would rather not magic string my DataTextField/Values on the dropdownlist after setting up the source as a List collection of objects.

I was thinking I could use the DataSource properties but it doesn't seem to like the couple of ways I tried.

WORKS BUT NOT IDEAL
//set the datasource to the returned List<Cart>
this.cartDdl.DataSource = CartManager.Load(WebProfile.Current.UserName);
//set the DataValueField to the Cart.ID property
this.cartDdl.DataValueField = "ID";//would rather use the obj property Cart.ID
//set the DataTextField to the Cart.Description property
this.cartDdl.DataTextField = "Description";//would rather use the obj property Cart.Description
//Bind the ddl to the datasource
this.cartDdl.DataBind();
HOW I WOULD THINK IT COULD WORK this.cartDdl.DataValueField = ((Cart)this.cartDdl.DataSourceObject).ID; this.cartDdl.DataTextField = ((Cart)this.cartDdl.DataSourceObject).Description;

View 2 Replies

Forms Data Controls :: DataGrid - How To Show The Datatextfield Value Of Dropdowlist

Aug 19, 2010

how to show the dropdownlist datatextfield selected text in the DataGrid

View 2 Replies

Web Forms :: How To Programmatically Set Template Fields Label Value Two One Of Two Fields Returned In A Sqldata...

Feb 8, 2011

I have a sql data souce that returns several columns of data, and they are displayed in a DetailsView on a pretty simple vb.net page. I'm stuggling with one field though for the details view.

It's a template field, and if ClientType=1 (this value is determined else where on the page), then the label in the template field should have Text='<%# Bind("ClientName") %>', but if the ClientType = 0, then the label in the template field should have Text='<%# Bind("ClientTemporaryName") %>'

How do I tell the details view to set the text for ClientName to one or the other?


[Code]....

View 3 Replies

C# - Creating A List Of Dataset Fields And Form Fields For Easy Updating?

Feb 25, 2011

I have a relatively complex dataset (numerous tables, some with multiple records) generated from reading in an XML file. I need to connect said dataset fields to an ASP form. At the moment I'm assigning them manually, like so in the pageload:

txt_first_init.Text = formData.ds.Tables["phrmHdrKey"].Rows[0]["first_init"].ToString();
txt_last_name.Text = formData.ds.Tables["phrmHdrKey"].Rows[0]["last_name"].ToString();
ddl_pregnancy_flag.SelectedValue = formData.ds.Tables["pPhrm"].Rows[0]["pregnancy_flag"].ToString();

And conversely when it's time to submit.

formData.ds.Tables["phrmHdrKey"].Rows[0]["first_init"] = txt_first_init.Text;
formData.ds.Tables["phrmHdrKey"].Rows[0]["last_name"] = txt_last_name.Text;
formData.ds.Tables["pPhrm"].Rows[0]["pregnancy_flag"] = ddl_pregnancy_flag.SelectedValue.ToString();

I did some looking into binding the textboxes (and dropdownlists, and checkboxes, and and and...) directly, but it seemed to be too many formats to use.

So this works fine, but as the number of fields increases, those load and unload lists are going to get unwieldy.

View 1 Replies

Forms Data Controls :: Databound Fields Vs Templete Fields In A GridView?

Aug 18, 2010

I am using TempleteFields for all columns in my GridView. In that columns I am using only some fields for customization but not all.

Is there any performance issue with Databound Fields vs Templete Fields in a GridView...?

Do I need to replace the remaining columns with Databound Columns instead of TempletField columns...?

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved