 |
| ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 11th, 2013, 09:48 AM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
I think I saw a way out. I kind of editing the template and I saw SelectedValue property. But it need code expression. Is that whr I should put my
'<%# Bind("Status") %>'
:D
|
|

August 11th, 2013, 09:50 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I am not sure what you mean. Can you elaborate? You already have that code, right? (Only in the Edit template; not in the Insert template)
And can you answer my question? Otherwise it's a bit hard to help.
Imar
|
|

August 11th, 2013, 09:59 AM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
I allowed Null for my Status column.
And I am still unable to find a way out. I am totally need your help..
|
|

August 11th, 2013, 10:20 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I don't think you understand my question. You may have allowed NULL for that column in the database, but is that what you want from an application's perspective? So is NULL a valid value for the State column at any stage of the application? It seems to me it isn't as your DropDownList only has three items. If NULL isn't valid, just delete the rows that now contain NULL and ensure you never insert NULL again.
Quote:
|
And I am still unable to find a way out. I am totally need your help..
|
There's not much point in sending me the application when I don't know how it should behave. So you should figure that out first. Can you describe how you want the application to behave? Is NULL a valid value? If so, why? If it's not, what are the valid choices? And why did you allow NULL in the database in the first place and why are you not deleting / updating those rows now?
Cheers,
Imar
|
|

August 11th, 2013, 10:42 AM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Ok. I think we lost the connection here. Let me explain in more details about my application. First, I am sorry for not being able to understand what you trying to say. Its because I am a beginner in this web thing.
Ok, here's the story. There is this page called PaparAduan (its objective is to View the complaints made by people & Edit the Status of the complaint from Status=New to Status= Pending or Complete). This is why I used dropdownlist for this option. So, in order to sort things nicely, I used FormView to view my data.
It is ONLY and ONLY to edit the Status from New to either Pending or Complete.
Inside my Database (which name Database.mdf), I have TableMaklumat (where I store all of the complaints) & UserTable. Let me give you details about my TableMaklumat here.
TableMaklumat has:
ID (PK)
Name (allowed null)
IC (allowed null)
Dates (allowed null)
Tel_No (allowed null)
Status (allowed null)
Complaint (allowed null)
My intention is to ONLY edit the Status.
But when I debug my coding, all of the dropdownlist value just wont entering my database. What I mean here is, when I hit Edit link, I was able to to the edit. But the value is Null in my database.
I assumed my dropdownlist was unable to select the value which I chose from my Dropdownlist.
It work fine if I manually insert using textbox. But that's another story.
I have deleted the row which has Null in it, and it is still the same.
Last edited by jlandan2; August 11th, 2013 at 10:49 AM..
|
|

August 11th, 2013, 10:46 AM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Code:
<tr>
<td><asp:Label ID="Label5" runat="server" Text="Status" Font-Bold="true"></asp:Label></td>
<td><asp:Label ID="Label6" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
<!-- <td><asp:TextBox ID="txtStatus" runat="server" Text='<%# Bind("Status") %>' /></td> -->
<td><asp:DropDownList ID="ddlStatus" runat="server" AutoPostBack="True" SelectedValue='<%# Bind("Status") %>' >
<asp:ListItem Text="New"></asp:ListItem>
<asp:ListItem Text="Pending"></asp:ListItem>
<asp:ListItem Text="Complete"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
this code is inside EditTemplate of FormView. Let me know if you need any explanation.
|
|

August 11th, 2013, 10:49 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
In that case, send me the code and I'll take a look. There's a fair chance you don't understand what I asking or saying, but maybe looking at your code will clear things up. To find my e-mail address, send me a message through http://imar.spaanjaars.com/contact I'll reply by mail so you know my address.
Cheers,
Imar
|
|

August 11th, 2013, 02:12 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Ah, I see now. Your Status column in the database is an nchar(10). So when you think it contains the value "New" (which exists in the drop down list), it actually contains the value "New_______" (New padded with 7 spaces) which does not exist in the drop down list. (Note: I am using underscores as this forum removes multiple consecutive spaces)
You can fix it as follows:
1. Open the table designer and change the data type of the Status column to n varchar(10).
2. Save the changes
3. Open the table and change the value for the existing records from "New_______" to "New".
4. Add the SelectedValue property back on the DropDownList control:
Code:
<asp:DropDownList ID="ddlStatus" runat="server" AutoPostBack="True" SelectedValue='<%# Bind("Status") %>'>
5. Done
Using an nchar is often not a good idea, unless you explicitly need the padding on your values. Use the nvarchar field instead as it's not padded with spaces.
Cheers,
Imar
Last edited by Imar; August 11th, 2013 at 02:14 PM..
Reason: Changed spaces to underscores
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

August 11th, 2013, 08:55 PM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
IT WORKS!!! First it still not working. But I gave it another try and it work perfectly :D..
I am so happy. THANK YOU VERY MUCH!!! God bless you multiple folds for a helping hand.
Thank you so much :)
|
|

October 15th, 2013, 01:01 AM
|
|
Registered User
|
|
Join Date: Mar 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ASP.NET 4
I am new in this topic but i want know more new things about ASP.NET 4 so i join this.
|
|
 |