I need this in around 6 to 7 places. When I changed it everywhere to the same as above, it worked in only 2 places but others are not working. Its the same but dont know whats the reason.
I have a ListView control that pulls a phone number from a db table. I'd like to format the phone number in the presentation layer to look like (###) ###-####.
The code line currently looks like this. The page displays the phone# but unformatted, i.e. 9999999999.
[Code]....
Based on other posts I've looked at in this forum, I've also tried:
<li>Phone: <%# String.Format("{0:(###) ###-####}", Databinder.Eval (Container.DataItem("Phone"))) %> with no success. In fact, this particular line throws an exception in my application (Input string not in the correct format).
The datatype I'm using in SQL is varchar(15)
The MSDN documentation for the String.Format method hasn't been very helpful thus far.
I want to export the grid data to excel then write the following code but the following lines of code are working at firefox3 but not at ie8(no response).
I'm trying to bind a List<String> to a DropDownList in a user control. I think I'm doing the right thing, but it seems that after my code executes the bindings are cleared. Here's the code for review!
User control: <asp:DropDownList ID="subjectNameDropDown" runat="server"/> <asp:DropDownList ID="yearLevelDropDown" runat="server"/> Auto-generated designed code-behind: public partial class NewSiteMetadataUserControl { protected global::System.Web.UI.WebControls.DropDownList subjectNameDropDown; protected global::System.Web.UI.WebControls.DropDownList yearLevelDropDown; } Code-behind: public partial class NewSiteMetadataUserControl : UserControl { protected override void CreateChildControls() { subjectNameDropDown = new DropDownList(); yearLevelDropDown = new DropDownList(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); EnsureChildControls(); // Attempt 1 List<String> subjectNames = GetSubjectValues(); foreach (var subjectName in subjectNames) subjectNameDropDown.Items.Add(subjectName); subjectNameDropDown.DataBind(); // Attempt 2 List<String> yearLevels = GetYearLevelValues(); yearLevelDropDown.DataSource = yearLevels; yearLevelDropDown.DataBind(); } }
Should this approach work? If it should, how can I debug what happens after the code executes?
I am accumulating a string for a SQL IN clause, so the format needs to be WHERE var IN ('string1','string2','string3',etc)
The strings are coming from a multiline textbox where they are pasted in from the user (one per line).
For some reason, I always get a space right after the tick and before the value in every value after the first. For instance my DataReader is only returning one record because the input string turns out like this:
SELECT * FROM Table WHERE ID IN ('12345',' 23456',' 34567')
Here is how I am processing the string, and I can't see why it is not taking that space out.
[Code]....
Even if I move the replace space (line 2) to the end of the code block, it still wont trim it out...
What I want to do is to replace number with a name. So if in the Month Column it receives five "1" it changes those 5 "1" to JANUARY.
Is it possible? This is because unfortunately I can only arrange my months by number and not by their name, this because of my queries and tables format, so, I thought maybe I can tell the gridview to change the month number to their relative month name.
I need to know how can I select a gridview row based on a query string data. In my case, the query string will contain the id that exist in the Table related to that grid. Is there a way to do this from the code behind? In other words, if I click a link with that specific query string, can I open the page and tell my grid to select a specific row based on the table row id?
I have a table that shows datas from a SQL DB. Some of those datas is numeric ( 1,2,3) and in another table I got the name that represents each number.
ex:
1= Goalie 2= Defence
So I did a Class_filters, in which I associate the number to the right string data.
I was wondering how can I do that in GridView? Is it possible?
Two text boxes on a formview need to be prefilled with data (coming from session variables) on page load. The formview is in Insert mode by default. Is that the reason why it shows blank fields...
How do I get two fields filled in with data on page load.. the user will enter the rest of the fields and Click on Insert.
[Code]....
I put break points and saw that the data was coming in as expected...but when the page loads with formview, the text boxes do not show any data.
this is probably very simple but I'm tearing my hair out!I'm using the FindControl method to try and grab the text in a textbox inside a DetailsView Template Field and display it on a label. Here is my code:
[Code]....
The word text has a squiggle underneath though and it causes an error as "System.Web.UI.Control' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'System.Web.UI.Control' could be found (are you missing a using directive or an assembly reference?)". I know the problem is that I'm treating this Control as a TextBox when it isn't, it's a Control. So how do I get from Control to TextBox so I can take the String and use it in code?
the client side validation is working for the adding date and time, but there is no validation firing for the count and room fields, I think i have coded them all the same, see sample for time and room below, maybe somebody see's something i missed? the validation group fires when the add button is clicked. also if possible I would like to get validation messages to appear in a validationsummary control that I already have coded and that is working when using the edit/update the rows presented with existing data.
So I am using EW + Access database to create a page.
This page contains two controls. First control is Dropdownlist which databinds with second control Listview.
This listview has paging on becuse of multiple pages. If I don't use QueryStringField paging works but if I use QueryStringField paging doesn't work and it goes back to first option of Dropdownlist.
I have a gridview within an updatepanel which allows paging and has a linkbutton that when clicked shows a modalpopup for editing records. This works fine in IE, Firefox, and Opera but I do not get a postback in Chrome or Safari?? I have other linkbuttons on the page that are within updatepanels but are not within gridviews that are working fine. I have scowered the web but cannot find a solution.