|
Hello,
I have a DataGrid (bound to a table) which outputs like this:
JobName - FullTime - PartTime<br />
=============================<br />
Dentist - 1 - 0<br />
Doctor - 1 - 0<br />
Baker - 0 - 1
I use 3 BoundColumns, as such:
asp:BoundColumn DataField="job_name" /<br />
asp:BoundColumn DataField="full_time" /<br />
asp:BoundColumn DataField="part_time" /
My question is this: How can I replace the 'FullTime' and 'PartTime' columns with a single column, which contains a string, either 'Full Time' or 'Part Time'?
I cannot make any changes to the database here.
Thank you!
|
|
|
|
|
How do you populate the Datagrid. If it's using a simple SQL query then you can append fields together to make a single field.
|
|
|
|
|
Like Sam said, you can populate a single field in the sql command and then bind it to the column. In addition, there are a couple of options here:
+ You can use a single column and use the ItemDataBound event of the grid control to specify the value for each cell of the column.
+ You can use a template column and put your data binding expression there to determine the value of the column from two fields full_time and part_time.
|
|
|
|
|
Hi all, I'm having what appears to be a very simple yet irritating problem.
I am using .Net 2003 with version 1.1 of the framework and I've installed the service packs. I am using VB as the programing language.
My problem is that a comma is appearing out of nowhere when I grap the .text value from the text box. For instance, let's say the user types "ABC" in the server side text box control in my web app. The value returned to my application is "ABC,". I do not know where the comma is coming from and can only imagine it is a bug of some sort. I haven't been able to find any documentation on this and was wondering if anybody has come across this problem. If so, is there a fix? I can use the REPLACE function for any comma's, but would rather not do that in the event a comma is the desired text.
Thanks a lot!
|
|
|
|
|
I've nevr heard of this happening, and I've done a lot of ASP.NET 1.1. Can you post the relevant code ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks for the response, but it concerns me that nobody's seen this.
I'm actually dynamically creating the text boxes and feeding the .text into a Crystal report as a parameter. However, even if I use some simple code, I get the same response. For instance...
dim x as string
x = textbox1.text
cache("text") = x
I redirect to the new page and in the page_load event, I have
label1.text = cache("text")
The label displays the text as "ABC," or sometimes ",ABC" (assuming ABC was typed into textbox1). Now, if I put
x = textbox1.text.replace(",",""), the problem goes away.
|
|
|
|
|
How can i disable a hyperlink column when the value inside is 0
Lets said is a monthly display and tehy are going to be reference to another page according to the value if the value inside the column is 1 or more i need to be hyperlink bu tif the value is 0 i do not need it to be hyperlink.
How can i achieve this
Thanks
|
|
|
|
|
If I can understand you correctly you want to disable the hyperlink in the column based on whether the value of the cell is 0.
First, you probably don't want to disable the entire column, only the individual cells in the column. You can use a template column to create a hyperlink or not depending on the value. You could also handle the databinding events such as ItemDataBound and configure the cell there.
only two letters away from being an asset
|
|
|
|
|
Yes that is right i need to disable the individual cells.
How can i use the template column sto let it know that it need to be able only when the cells has a value of 1 or more
Thanks
|
|
|
|
|
<TemplateColumn>
<% if cell.value == 0 %>
<asp:Hyperlink
<% else %>
<asp:Label
</TemplateColumn>
only two letters away from being an asset
|
|
|
|
|
I've been putting together the first pages of a site and clicked the debug button and get a message that I can't debug. In going through the exercise of settings to debug I come across a page of system requirements- ASP.NET Debugging: System Requirements. It lists Visual Studio Edition,,Express, Standard and Pro/Team. And has a nice list of "no's" for visual basic, C#, C++ J# and Visual Web Developer beside express.
I have difficulty believing MSFT goes to the trouble of writing the visual web development 2005 express application and doesn't have any way to debug it, except to buy a Professional edition of Windows XP. I have the Windows Media Center Edition of Windows. Further down the page it lists Windows XP Professional as needed for local debugging. Which is unfortunate. Too bad when I downloaded VWD express it didn't say I need a professional version of windows.
I am sure I don't need all of windows XP Professional. I'll bet I already have a lot of it, whatever it is. Is there some way of getting the routines I need for debugging and not loading an entire operating system into a computer that works fine as it is?
Mark H.
|
|
|
|
|
have you checked out the video on debugging here :[^]
|
|
|
|
|
I'm not sure, but I'd guess that the major missing bit would be IIS (think the exp editions use cassini)...I believe you can install it from an XP pro disk if you can get one....
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Can I apply CSS attributes such as background-color to user controls. For example the page I’m dealing with has multiple user controls with tag prefix =”UserCon1” and tagName = “MyHeader” and tag prefix =”UserCon1” and tagName = “MyFooter”.
Now I’m doing this
<br />
UserCon1 { background-color: ; }<br />
But it doesn’t seem to be working. Is it possible to change the values of user controls this way??? If so please could you tell me what I’m doing wrong here.
Thanks
~TINA
|
|
|
|
|
You can't apply it to the user control itself. A user control is just a container for other controls, it isn't a rendered element itself. You could place all of you controls within the user control in a div and set the backgound of the div.
only two letters away from being an asset
|
|
|
|
|
Thanks alot Mark, I tried that and it worked great!
Thanks
|
|
|
|
|
In my webform i
have 4 dropdowns , 5 textboxes and 6 radiobuttons 5 buttons.
if i select 1st ddl then relevant data will be displayed in 2nd ddl.
if i select 2nd ddl then relevant data will be displayed in 3rd ddl.
if i select 3rd ddl then relevant data will be displayed in 4th ddl.
1st ddl,2nd ddl,3rd has autopost back=true;
In this two radio buttons has autopost back=true;
whenever iam selecting one of the radio buttons 3rd ddl is going to the zero index
i.e.. whenever data is sent to server then 3rd ddl is lossing its selected value and then showing the value with zero index.
i already binded the data at the required places.but the problem is not solved.
emial to---- kemisetti_net@yahoo.com
|
|
|
|
|
It's because you're posting back....the simplest way to do this would be to use javascript's document.getElementById method to get hold of the dropdown, and set its value manually...
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
wrote: i already binded the data at the required places
And where is that? It sounds like the problem is that you are binding the 3rd ddl and wiping out the existing items and selections.
only two letters away from being an asset
|
|
|
|
|
I have the following code:
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Load
Dim strConn As String = MRMFunctions.WebConfigConnString
dsTitles.ConnectionString = strConn
Dim strTitleSQL = "SELECT * FROM tblTitles WHERE [Deleted] = 0;"
dsTitles.SelectCommand = strTitleSQL
cboTitle.DataSourceID = dsTitles.ID.ToString
cboTitle.DataTextField = "Title"
cboTitle.DataValueField = "TitleID"
End Sub
The purpose of this code is to retrieve the connection string from the Web.Config file and place that into a variable called strConn.
Next, I assign the SqlDataSource(dsTitles)control to that connection string.
I retrieve the data I want from the Sql Server Database with the strTitleSQL statement by selecting every field from the tblTitles table where the field named ‘Deleted’ is equal to false. I set the Datasource select command to the strTitleSQL variable.
I am now going to databind the control cboTitle by assigning the DataSourceID equal to the dsTitles datasource ID.
I assign the cboTitle.DataTextField to the Title field from the SQL statement. This is the information that will be placed in the drop down list.
Logically, I should be able to assign the record ID number to the DataVieldValue by assigning the cboTitle.DataValueField to the TitleID field. Instead I am getting the error, “Conversion from string ‘TitleID’ to type Decimal is not valid.”
I understand that it is seeing the string ‘TitleID’ as the string for the DataValueField. What I don’t understand is why is the DataTextField is seeing ‘Title’ as the field name from the SQL statement, but the DataValueField is not seeing ‘TitleID’ as the same?
Thank you,
Quecumber256
|
|
|
|
|
It seems the error is coming from somewhere else where you cast that string to the decimal type. Is that all your sample code? If so, can you also post the stack error?
|
|
|
|
|
You are correct. I was trying to retrieve the value from the cboTitle.DataValueField instead of decTitleID = CDec(cboTitle.SelectedValue)
I get the record ID number this way.
Thank you,
Quecumber256
|
|
|
|
|
Hi, I have a 2 textboxes .. one for the username and one for the password. Now when i try to login, i enter the username then the password and then when i press the ENTER key i wish that the button (Login) will be clicked. But right now when i wrote the user and pass and press the enter key it does not make anything
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
Go to the login form and set the AcceptButton property to be the ID of your Login button. You can also set the CancelButton if your login form has one.
|
|
|
|
|
hi, i am using asp.net .. i cannot see any acceptbuttons in the property .. can you help me please
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|