Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #21 (permalink)  
Old August 11th, 2013, 09:48 AM
Registered User
Points: 47, Level: 1
Points: 47, Level: 1 Points: 47, Level: 1 Points: 47, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2013
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #22 (permalink)  
Old August 11th, 2013, 09:50 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #23 (permalink)  
Old August 11th, 2013, 09:59 AM
Registered User
Points: 47, Level: 1
Points: 47, Level: 1 Points: 47, Level: 1 Points: 47, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2013
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I allowed Null for my Status column.

And I am still unable to find a way out. I am totally need your help..
Reply With Quote
  #24 (permalink)  
Old August 11th, 2013, 10:20 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #25 (permalink)  
Old August 11th, 2013, 10:42 AM
Registered User
Points: 47, Level: 1
Points: 47, Level: 1 Points: 47, Level: 1 Points: 47, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2013
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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..
Reply With Quote
  #26 (permalink)  
Old August 11th, 2013, 10:46 AM
Registered User
Points: 47, Level: 1
Points: 47, Level: 1 Points: 47, Level: 1 Points: 47, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2013
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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.
Reply With Quote
  #27 (permalink)  
Old August 11th, 2013, 10:49 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #28 (permalink)  
Old August 11th, 2013, 02:12 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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 nvarchar(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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!

Last edited by Imar; August 11th, 2013 at 02:14 PM.. Reason: Changed spaces to underscores
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
jlandan2 (August 11th, 2013)
  #29 (permalink)  
Old August 11th, 2013, 08:55 PM
Registered User
Points: 47, Level: 1
Points: 47, Level: 1 Points: 47, Level: 1 Points: 47, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2013
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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 :)
Reply With Quote
  #30 (permalink)  
Old October 15th, 2013, 01:01 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.NET 4

I am new in this topic but i want know more new things about ASP.NET 4 so i join this.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
using dropdown list sophia BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 October 31st, 2009 02:46 PM
Dropdown list maha .NET Framework 2.0 7 April 28th, 2007 12:32 AM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM
HELP WITH DROPDOWN LIST enavas Excel VBA 1 April 6th, 2004 02:08 PM



All times are GMT -4. The time now is 08:28 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.