Forms Data Controls :: Replace Dropdown With Read Only Text Options?

Jan 11, 2010

I'm using a book to create a shopping site and need to change the following code so that the current dropdown list, of colour options, is replaced by just read only text. I'm a novice and despite best efforts I can't fathom it out. If anyone can change the code for me I would be extremely grateful.

The code below is the code-behind page for a Product List page where I want each product displayed to also display its colour options as just text (I don't need the shopper to select a colour choice until they click through to the detail page)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class UserControls_ProductsList : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
PopulateControls();
}
private void PopulateControls()
{
// Retrieve DepartmentID from the query string
string departmentId = Request.QueryString["DepartmentID"];
// Retrieve CategoryID from the query string
string categoryId = Request.QueryString["CategoryID"];
// Retrieve Page from the query string
string page = Request.QueryString["Page"];
if (page == null) page = "1";
// Retrieve Search string from query string
string searchString = Request.QueryString["Search"];
// How many pages of products?
int howManyPages = 1;
// pager links format
string firstPageUrl = "";
string pagerFormat = "";
// If performing a product search
if (searchString != null)
{
// Retrieve AllWords from query string
string allWords = Request.QueryString["AllWords"];
// Perform search
list.DataSource = CatalogAccess.Search(searchString, allWords,
page, out howManyPages);
list.DataBind();
// Display pager
firstPageUrl = Link.ToSearch(searchString, allWords.ToUpper() == "TRUE", "1");
pagerFormat = Link.ToSearch(searchString, allWords.ToUpper() == "TRUE", "{0}");
}
// If browsing a category...
else if (categoryId != null)
{
// Retrieve list of products in a category
list.DataSource =
CatalogAccess.GetProductsInCategory(categoryId, page, out howManyPages);
list.DataBind();
// get first page url and pager format
firstPageUrl = Link.ToCategory(departmentId, categoryId, "1");
pagerFormat = Link.ToCategory(departmentId, categoryId, "{0}");
}
else if (departmentId != null)
{
// Retrieve list of products on department promotion
list.DataSource = CatalogAccess.GetProductsOnDeptPromo
(departmentId, page, out howManyPages);
list.DataBind();
// get first page url and pager format
firstPageUrl = Link.ToDepartment(departmentId, "1");
pagerFormat = Link.ToDepartment(departmentId, "{0}");
}
else
{
// Retrieve list of products on catalog promotion
list.DataSource =
CatalogAccess.GetProductsOnFrontPromo(page, out howManyPages);
list.DataBind();
// have the current page as integer
int currentPage = Int32.Parse(page);
}
// Display pager controls
topPager.Show(int.Parse(page), howManyPages, firstPageUrl, pagerFormat, false);
bottomPager.Show(int.Parse(page), howManyPages, firstPageUrl, pagerFormat, true);
}
// Executed when each item of the list is bound to the data source
protected void list_ItemDataBound(object sender, DataListItemEventArgs e)
{
// obtain the attributes of the product
DataRowView dataRow = (DataRowView)e.Item.DataItem;
string productId = dataRow["ProductID"].ToString();
DataTable attrTable = CatalogAccess.GetProductAttributes(productId);
// get the attribute placeholder
PlaceHolder attrPlaceHolder = (PlaceHolder)e.Item.FindControl("attrPlaceHolder");
// temp variables
string prevAttributeName = "";
string attributeName, attributeValue, attributeValueId;
// current DropDown for attribute values
Label attributeNameLabel;
DropDownList attributeValuesDropDown = new DropDownList();
// read the list of attributes
foreach (DataRow r in attrTable.Rows)
{
// get attribute data
attributeName = r["AttributeName"].ToString();
attributeValue = r["AttributeValue"].ToString();
attributeValueId = r["AttributeValueID"].ToString();
// if starting a new attribute (e.g. Color, Size)
if (attributeName != prevAttributeName)
{
prevAttributeName = attributeName;
attributeNameLabel = new Label();
attributeNameLabel.Text = attributeName + ": ";
attributeValuesDropDown = new DropDownList();
attrPlaceHolder.Controls.Add(attributeNameLabel);
attrPlaceHolder.Controls.Add(attributeValuesDropDown);
}
// add a new attribute value to the DropDownList
attributeValuesDropDown.Items.Add(new ListItem(attributeValue, attributeValueId));
}
}
}

View 22 Replies


Similar Messages:

Forms Data Controls :: Genarate Gridview Options In Dropdown

Jan 6, 2010

I have two dropdown....One is showing "From Date" and another one is showing "To Date"...Based on selection of date I would like to generate grid view with Mon name as column header name..Like if user select From Date- 01 jan,2009 TO Date- 01 April,2009Then I would like to generate grid view column header

View 2 Replies

Web Forms :: Treeview / SiteMapDataSource - Get Tree Layout That Matches The Numbers Of Options But No Text On Any Of Options To Click

Jan 18, 2011

I have a Default.aspx program that contains a Treeview with a SiteMapDataSource. I also have a web.sitemap loaded up with urls. When I run the deafult app I get the tree layout that matches the numbers of options but no text on any of the options to click.

View 1 Replies

Web Forms :: Change Text And Make Read-only After Dropdown Is Selected?

Feb 15, 2011

I think this is almost impossible but I would like to ask.

I have a dropdown in my page:

The Name Dropdown is combined with item name / manufacturer name

This is what I want to do:

When a manager select a name, The text on the dropdown change to only item name and read only. (example: 44 inch Side Brushes)

The Manufacturer Textbox automatically retrieves the manufacturer name and read only.

View 5 Replies

Forms Data Controls :: Replace Text In GridView Or Something?

Nov 6, 2010

I have big problem I have a table where the column is "Enabled" datatype = bit.

In this column I have data True / False. The show GridView column 'Enabled'. Problem is, as everywhere in this column, write True / False. How, in view of this information in the GridView displayed: True = Verified, False / UnVerified GridView, column is "Enabled"

Column Enabled:
No False
No True
Column Enabled I want this
Unverified
Verified

It should probably change the text, or something like that.

View 2 Replies

Forms Data Controls :: Replace Text With Icon?

Sep 28, 2010

I've got a gridview on my page that gets its infomation from a database. One of the columns shows whether a news article is featured or not. It currently displays a 1 or 0.

I would like to change it so that it shows a tick icon if it's a 1, or a nbsp; if it's 0.

View 2 Replies

Forms Data Controls :: Access Gridview Column 2 And For Each Row Replace Text

Mar 31, 2011

i want to access gridview collumn 2 and for each row replace the text that is there with a "*" because its a password fields so instead on show the pass hide it with * so its more or less this but... see comment line

[Code]....

View 3 Replies

Data Controls :: Replace DropDownList Text With Value On Selected Index Changed

Jan 5, 2014

I want to create a drop down list, where user can view the code name and the name the code when they click on the drop down list.

But after they choose, only the code is appeared. This is my current coding as for now. 

<asp:DropDownList ID="ddlcodetype" runat="server">
<asp:ListItem Selected="True">-</asp:ListItem>
<asp:ListItem>DK Deck</asp:ListItem>
<asp:ListItem>EG Engine</asp:ListItem>
<asp:ListItem>CT Catering</asp:ListItem>
<asp:ListItem>OT Others</asp:ListItem>
</asp:DropDownList>

With this, both my name and the code name are appeared. 

View 1 Replies

Forms Data Controls :: Making Read Only Text A Different Color

Mar 30, 2011

How do I make A, B and D navy blue?

Region

Stuff

Stuff

tried this just for one of the cells but it's not working what am I missing?

[Code]....

View 1 Replies

Forms Data Controls :: How To Read Text File Data To Data Grid

Jul 7, 2010

i am having my text file data as follows

101011111111101111111111007060540A0941

I would like read this data and place it to the Corresponding cell in data grid.

View 7 Replies

Web Forms :: Dropdown List Does Not Allow To Select Options In Firefox

Apr 13, 2010

I have a drop down list with two options Score and status. On selecting score select score i display a MultihandleSliderExtender to select the score range ex: 10 to 20 and on selecting status i display dropdown list . On displaying one option i make the other as not visible.

Now comes the problem in Firefox (works properly in IE) when i select score and then try to change my option to status it does not allow me to do so i.e the mouse over event on the dropdownlist is not working.

View 1 Replies

Web Forms :: How To Search And Replace Text In Rich Text Format Document

Nov 23, 2013

How to use pattern replacement in the RTF?. For example you can add a placeholder like {USER_FIRST_NAME} in the RTF document. When the user clicks the download button, your application can take the information from the database and replace every instance of {USER_FIRST_NAME} with the data from the database....

View 1 Replies

Forms Data Controls :: Display Help Text Based On DropDown Selection Value?

Jan 4, 2011

I have drop down selection box as follow...

1 - Car
2 - Plane
3 - Train.

Now, based on user selection say, 'Car', I want to display Help text associated with selection on page. Help text description - 1000 characters. Now, how do I fetch Help Text Description from? should I store in Session scope or Application Scope or fetch from Database based on drop down selection.

View 2 Replies

Forms Data Controls :: Searching Database By A Dropdown List AND Text Box

Aug 10, 2010

I am very new to coding in asp.net, I've never done anything before, but heres my problem, I have a Microsoft SQL Server 2005 Database, and basically I need to be able to search that database by 3 different things, basically there is tons of data, and I need to be able to search by a member ID, a location, and a group name So basically I wanted a drop down list, with these 3 column names, and than a search box where you can actually type in what you are looking for, than have the results display, I have been trying to do this with gridview, but I can't seem to get it to work correctly

View 14 Replies

Forms Data Controls :: How To Update Text Of A Textbox Placed Inside A Gridview (template) By A Dropdown List

Nov 13, 2010

I have a text box placed inside a gridview(template) . I need to update its value by a dropdown list event (Selected Item Changed event) placed in the same gridVew. But The problem is that , I need to update the text box of the same row the dropdown list (whose textChange Event haas been fired)

[code]....

View 1 Replies

Visual Studio :: Read .txt File And Be Able To Do Certain Options Depending On Contents

Jan 27, 2010

I am trying to get a .txt file to be read by my server application. My problem is that i cannot get it to read user information. I would like for my application to do something like if there is a "#", to read the next 2 lines down for more information.

View 4 Replies

C# - Adding Custom Options In Bound Dropdown?

Apr 5, 2010

I have a bound dropdown list populated with a table of names through a select, and databinding. it shoots selectedindexchanged that (through a postback) updates a certain gridview.What happens is, since it runs from changing the index, the one that always comes selected (alexander) can only me chosen if you choose another one, then choose alexander. poor alexander.What I want is to put a blanc option at the beginning (default) and (if possible) a option as second.I can't add this option manually, since the binding wipes whatever was in the dropdown list and puts the content of the datasource.

View 2 Replies

Find And Replace Linebreaks In File Read From Disk

Sep 4, 2010

I have a css file which I want to read from disk and in that content I want to find and replace all linebreaks (do I look for vbCrlf or ...?)

Public Shared Function GetFileContents(ByVal FullFilename As String) As String
Dim filecontents As String = ""
If File.Exists(FullFilename) Then
Dim objStreamReader As StreamReader
objStreamReader = File.OpenText(FullFilename)
filecontents = objStreamReader.ReadToEnd()
objStreamReader.Close()
End If
Return filecontents
End Function

So in the returned variable "filecontents" I want to find and replace any linebreaks.

FILE: style.css

#progress{color:#000;width:500px;height:30px;padding:0px;clear:both;}
#progress ul{list-style:none;padding:0px;margin: auto;display:block;}
#progress ul li{list-style:none;display:inline;float:left;width:auto;height:30px;padding:0px;line-height:30px; font-family:Arial, Helvetica, sans-serif; font-size:13px;}

View 1 Replies

Web Forms :: Regex.Replace / Capture The Text That Was Removed?

Feb 8, 2010

The regular expression removes the html, I then need to assign it to a button,

How do I capture the text that was removed?

[Code]....

View 1 Replies

Forms Data Controls :: Dropdown That Inserts Data Vis Procedure If The Gridview Doesn't Have Value For The Dropdown Selection

Sep 3, 2010

i have a dropdown with month names if the user has data for the month tht is selected then gridview displays the rows with day nos as per the month but if the gridview has no data for the same the dropdown or gridview via some event should call a insert procedure to insert data into the table for tht month with daynos ad rebind the gridview witht the rows just created

View 6 Replies

Web Forms :: Populating A Text Box With Data From DropDown List On Page Load?

Mar 9, 2011

I have a dropdown control that has a list of names in it called PlayerNameDropDownList_Insert and a textBox called PlayerName.

When I select a name from the dropdown it populates the textbox correctly.However, when the page opens the first name is selected in the dropdown but nothing in the textbox. How can I get the textbox to populate with the value of the dropdown at pageload?

[Code]....

View 4 Replies

Forms Data Controls :: Gridview Populate Dropdown Based On Another Dropdown?

Mar 4, 2011

I have a gridview where i have two fields. one is product and second is sub category.

I need to do 2 things.

1. I need to populate the two combos from the database. But depending what is selected in dropdown 1 this will determine what needs to be populated in drop down 2?

how can i achieve this?

View 2 Replies

Forms Data Controls :: 1st Dropdown To Be Loaded On The Basis Of Selection Of 2nd Dropdown?

Oct 14, 2010

I have two dropdown linked with sqldatasources.When I select item in ddl1 then on the basis of selection ddl2 is being loaded.Is there any possiblity that if I select ddl2 then ddl1 will also load on the basis of selection?

View 3 Replies

Forms Data Controls :: GridView Display Options With IE8

Mar 25, 2010

I've been trying to figure this one out for hours now. I'm trying to figure out why IE8 insists on displaying my gridview differently than IE7 and other browsers. First of all, width is set to 100%. In IE7, the gridview uses up the entire space of the container it's in (like it should). In IE8, the gridview only takes up the space that is required by its content

View 3 Replies

Forms Data Controls :: Populate GridView With Data From Database And Other Options?

Jan 20, 2011

I need to create a gridview to show in each row, some columns from the SQL Database, and in other columns I want to have text fields, buttons and DropDownLists!

This GridView is to display the users of the web application.

First columns are name, email, and other stuff that can be easly queried to the SQL database.

Then, I need to have a column with one text field, and some buttons, in the text field the AdminUser should be able to insert some text and then click in a button to change the email/pass from the user represented in that line.

The other field I need, is a DropDownList that shows by default the Role of the user of the row, but we can choose another role and apply it, with a button in the same cell!

If I create a code-Behind query and populate the GridView, I don't know how to insert textbox's, button's, DropDownList's

If I create the GridView with the wizard, I can had TemplateFields, but I don't know how to associate the query with the BoundFiels where should be the name/email of the users.

Other problem, is that, even If I get to construct my GridView with sucess, How can I reference the row? So I can apply the changes?

View 2 Replies







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