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
  #1 (permalink)  
Old August 2nd, 2010, 03:06 AM
Registered User
 
Join Date: Aug 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Question DropDown List and user input

Using DropDownList on a webform, FORMVIEW, ASP.NET 4 Visual Studio 2010
I need help with this scenario:

I need users to fill out a field on an online ASP.NET 4 webform FormView, like say, "Title." I have a DropDownList on which I have placed these titular items: "Mrs", "Mr", "Dr", etc. The user is presented with only those choices. When (s)he picks one, say, "Dr" off the DropDownList, then, "Dr" is inserted into the "Title" field of the database. How do I do that?

All previous responses have assumed that the datasource should come from the bound field of the database, but the reality and practicality is that you present a static dropdown list from which the user makes a selection. Now, that selection needs to be posted back to the appropriate field in the Table of the database, to complete this process. How do I do that?.

Any help?

Thanks in advance.
Oguchi

Thanks again.
Reply With Quote
  #2 (permalink)  
Old August 2nd, 2010, 04:27 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

Hi there,

If by "previous responses" you also mean the e-mail I sent you, then you may not have understood my answer. Take a look at page 467 and 468. It shows you how to do this for a bound drop down. Simply skip the datasource and use your manually created items instead.

So rather than creating a bound drop down, you simply create a static one and hook up its SelectedValue to the Title field of the data you're using in the FormView, like this:

Code:
<InsertItemTemplate>
  Name:
  <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
  <br />
  Title:
  <asp:DropDownList ID="DropDownList1" runat="server" 
           SelectedValue='<%# Bind("Title") %>'>
    <asp:ListItem>Mrs.</asp:ListItem>
    <asp:ListItem>Mr.</asp:ListItem>
  </asp:DropDownList>
  <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
              CommandName="Insert" Text="Insert" />
  &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"
    CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
This code is used in a FormView that uses SELECT Id, Name, Title FROM Person as the select statement in a SqlDataSource. When the InsertItemTemplate is shown, you see a drop down list. When the item is saved, the selected value of the DropDownList is inserted in the Title column of the Person table.

Hope this helps,

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
  #3 (permalink)  
Old August 3rd, 2010, 03:16 AM
Registered User
 
Join Date: Aug 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This works! Thanks.

If you try this and at first it does not work, try posting the same code between the EDITITEM tags: that's what I had to do.
Thanks again, Imar.
Reply With Quote
  #4 (permalink)  
Old August 3rd, 2010, 03:31 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

You said something about "Inserted" in the database, so that seemed to imply an Insert scenario.

As explained in the book in detail, you can indeed do the same for the EditItemTemplate, which gets shown when the users edits an existing item in the database.

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
  #5 (permalink)  
Old August 6th, 2010, 09:06 AM
Registered User
 
Join Date: Aug 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default nice

everything is nice and everything fine will
Reply With Quote
  #6 (permalink)  
Old August 10th, 2013, 05:15 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

Hi there,

I am facing the similar problem and I tried your coding. But it doesnt run. In your coding, u wrote SelectedValue='<%# Bind("Title") %>', but when i wrote it in my coding, there is no SelectedValue Property..


Let me explain about my situation. I have this FormView and when i want to edit it, i'll just click edit. Right? But in one of the fields that i want to edit, I want to put a dropdownlist (With item New, Pending & Complete). It is fine until when i want the data to enter the database. Inside the database, these New, Pending & Complete should enter "status".. but it did not. How can i select those value from dropdownlist?

Like I said, I tried ur coding but it didnt run cos the there is no "selectedValue" properties.

I am using microsoft visual studio 2008
Reply With Quote
  #7 (permalink)  
Old August 10th, 2013, 08:23 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

Hi there,

A DropDownList does have a SelectedValue property so the code should work.
Maybe you're using a different type of control? Can you post your relevant code?

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
  #8 (permalink)  
Old August 10th, 2013, 09:12 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

Here's my code. Just this part that left me puzzled. Please help me through this

<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"
onselectedindexchanged="ddlStatus_SelectedIndexCha nged">
<asp:ListItem>New</asp:ListItem>
<asp:ListItem>Pending</asp:ListItem>
<asp:ListItem>Complete</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
Reply With Quote
  #9 (permalink)  
Old August 10th, 2013, 09:26 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

This is my entier code since you might need all the codes to detect whr my mistakes are. And I need my dropdownlist (ddlStatus) at Edit template to be able to insert data into my database.

Code:
<%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="~/MasterPage.master" CodeFile="PaparAduan.aspx.vb" Inherits="PaparAduan" %>

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.Configuration" %>

<asp:Content ID="content1" ContentPlaceHolderID="ContentBody" runat="server">
     
     
      <asp:FormView ID="FormView1" runat="server" AllowPaging="True" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
            CellSpacing="2" DataKeyNames="ID_Aduan" DataSourceID="SqlDataSource1" GridLines="Both" Width="900px">
        <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
        <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
        <EditItemTemplate>        
            <table>
                <tr>
                    <td><asp:Label ID="Label1" runat="server" Text="Bil" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label2" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="txtID_Aduan" runat="server" Text='<%# Eval("ID_Aduan") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label3" runat="server" Text="Tarikh Aduan" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label4" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="txtTarikh_Aduan" runat="server" Text='<%# Bind("Tarikh_Aduan") %>' ReadOnly="true" Enabled="False" /></td>
                </tr>
                <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>New</asp:ListItem>
                        <asp:ListItem>Pending</asp:ListItem>
                        <asp:ListItem>Complete</asp:ListItem>
                        </asp:DropDownList>               
                    </td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label7" runat="server" Text="Nama Pengadu" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label8" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="Nama_PengaduTextBox" runat="server" Text='<%# Bind("Nama_Pengadu") %>' ReadOnly="true" Enabled="False" /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label9" runat="server" Text="No IC Pengadu" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label10" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="IC_PengaduTextBox" runat="server" Text='<%# Bind("IC_Pengadu") %>' ReadOnly="true" Enabled="False" /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label11" runat="server" Text="No Telefon Pengadu" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label12" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="Tel_PengaduTextBox" runat="server" Text='<%# Bind("Tel_Pengadu") %>' ReadOnly="true" Enabled="False"/></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label13" runat="server" Text="Negeri" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label14" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="NegeriTextBox" runat="server" Text='<%# Bind("Negeri") %>' ReadOnly="true" Enabled="False" /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label15" runat="server" Text="Zon Payphone" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label16" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="Zon_PayphoneTextBox" runat="server" Text='<%# Bind("Zon_Payphone") %>' ReadOnly="true" Enabled="False" /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label17" runat="server" Text="Kawasan Payphone" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label18" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="Kwsn_PayphoneTextBox" runat="server" Text='<%# Bind("Kwsn_Payphone") %>' ReadOnly="true" Enabled="False" /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label19" runat="server" Text="No Telefon Payphone" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label20" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="No_Tel_PayphoneTextBox" runat="server" Text='<%# Bind("No_Tel_Payphone") %>' ReadOnly="true" Enabled="False" /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label21" runat="server" Text="Aduan Payphone" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label22" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="Aduan_PayphoneTextBox" runat="server" Text='<%# Bind("Aduan_Payphone") %>' ReadOnly="true" Enabled="False" /></td>
                </tr>
                <tr>
                    <!--<td><asp:Button ID="btnUpdate" runat="server" Text="Update" /></td> -->
                    <td><asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                            CommandName="Update" Text="Update" onclick="UpdateButton_Click" /></td> 
                    <td><asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /></td>
                </tr>
            </table>
                     
        </EditItemTemplate>
        <InsertItemTemplate>
            <table>
                <tr>
                    <td><asp:Label ID="Label23" runat="server" Text="Tarikh Aduan" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label24" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="Tarikh_AduanTextBox" runat="server" Text='<%# Bind("Tarikh_Aduan") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label25" runat="server" Text="Status" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label26" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label27" runat="server" Text="Nama Pengadu" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label28" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="Nama_PengaduTextBox" runat="server" Text='<%# Bind("Nama_Pengadu") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label29" runat="server" Text="No IC Pengadu" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label30" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="IC_PengaduTextBox" runat="server" Text='<%# Bind("IC_Pengadu") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label31" runat="server" Text="No Telefon Pengadu" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label32" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="Tel_PengaduTextBox" runat="server" Text='<%# Bind("Tel_Pengadu") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label33" runat="server" Text="Negeri" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label34" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="NegeriTextBox" runat="server" Text='<%# Bind("Negeri") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label35" runat="server" Text="Zon Payphone" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label36" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="Zon_PayphoneTextBox" runat="server" Text='<%# Bind("Zon_Payphone") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label37" runat="server" Text="Kawasan Payphone" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label38" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="Kwsn_PayphoneTextBox" runat="server" Text='<%# Bind("Kwsn_Payphone") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label39" runat="server" Text="No Telefon Payphone" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label40" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="No_Tel_PayphoneTextBox" runat="server" Text='<%# Bind("No_Tel_Payphone") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label41" runat="server" Text="Aduan Payphone" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label42" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:TextBox ID="Aduan_PayphoneTextBox" runat="server" Text='<%# Bind("Aduan_Payphone") %>' /></td>
                </tr>
                <tr>
                    <td><asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" /></td>
                    <td><asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /></td>
                </tr>
            </table>
        </InsertItemTemplate>
        <ItemTemplate>
            <table>
                <tr>
                    <td><asp:Label ID="Label43" runat="server" Text="Bil" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label44" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="ID_AduanLabel" runat="server" Text='<%# Eval("ID_Aduan") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label45" runat="server" Text="Tarikh Aduan" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label46" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Tarikh_AduanLabel" runat="server" Text='<%# Bind("Tarikh_Aduan") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label47" runat="server" Text="Status" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label48" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="StatusLabel" runat="server" Text='<%# Bind("Status") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label49" runat="server" Text="Nama Pengadu" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label50" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Nama_PengaduLabel" runat="server" Text='<%# Bind("Nama_Pengadu") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label51" runat="server" Text="No IC Pengadu" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label52" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="IC_PengaduLabel" runat="server" Text='<%# Bind("IC_Pengadu") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label53" runat="server" Text="No Telefon Pengadu" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label54" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Tel_PengaduLabel" runat="server" Text='<%# Bind("Tel_Pengadu") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label55" runat="server" Text="Negeri" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label56" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="NegeriLabel" runat="server" Text='<%# Bind("Negeri") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label57" runat="server" Text="Zon Payphone" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label58" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Zon_PayphoneLabel" runat="server" Text='<%# Bind("Zon_Payphone") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label59" runat="server" Text="Kawasan Payphone" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label60" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Kwsn_PayphoneLabel" runat="server" Text='<%# Bind("Kwsn_Payphone") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label61" runat="server" Text="No Telefon Payphone" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label62" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="No_Tel_PayphoneLabel" runat="server" Text='<%# Bind("No_Tel_Payphone") %>' /></td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label63" runat="server" Text="Aduan Payphone" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Label64" runat="server" Text=":" Font-Bold="true"></asp:Label></td>
                    <td><asp:Label ID="Aduan_PayphoneLabel" runat="server" Text='<%# Bind("Aduan_Payphone") %>' /></td>
                </tr>
                <tr>
                    
                 <td><asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" /></td> 
                    
                </tr>
            </table>            
        </ItemTemplate>
        <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
    </asp:FormView>


    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        DeleteCommand="DELETE FROM [TableMaklumat] WHERE [ID_Aduan] = @ID_Aduan" 
        InsertCommand="INSERT INTO [TableMaklumat] ([Nama_Pengadu], [IC_Pengadu], [Tarikh_Aduan], [Tel_Pengadu], [Zon_Payphone], [Kwsn_Payphone], [No_Tel_Payphone], [Aduan_Payphone], [Negeri], [Status]) VALUES (@Nama_Pengadu, @IC_Pengadu, @Tarikh_Aduan, @Tel_Pengadu, @Zon_Payphone, @Kwsn_Payphone, @No_Tel_Payphone, @Aduan_Payphone, @Negeri, @Status)" 
        SelectCommand="SELECT * FROM [TableMaklumat]" 
        UpdateCommand="UPDATE [TableMaklumat] SET [Nama_Pengadu] = @Nama_Pengadu, [IC_Pengadu] = @IC_Pengadu, [Tarikh_Aduan] = @Tarikh_Aduan, [Tel_Pengadu] = @Tel_Pengadu, [Zon_Payphone] = @Zon_Payphone, [Kwsn_Payphone] = @Kwsn_Payphone, [No_Tel_Payphone] = @No_Tel_Payphone, [Aduan_Payphone] = @Aduan_Payphone, [Negeri] = @Negeri, [Status] = @Status WHERE [ID_Aduan] = @ID_Aduan">
        <DeleteParameters>
            <asp:Parameter Name="ID_Aduan" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Nama_Pengadu" Type="String" />
            <asp:Parameter Name="IC_Pengadu" Type="Int64" />
            <asp:Parameter Name="Tarikh_Aduan" Type="String" />
            <asp:Parameter Name="Tel_Pengadu" Type="String" />
            <asp:Parameter Name="Zon_Payphone" Type="String" />
            <asp:Parameter Name="Kwsn_Payphone" Type="String" />
            <asp:Parameter Name="No_Tel_Payphone" Type="String" />
            <asp:Parameter Name="Aduan_Payphone" Type="String" />
            <asp:Parameter Name="Negeri" Type="String" />
            <asp:Parameter Name="Status" Type="String" />
            <asp:Parameter Name="ID_Aduan" Type="Int32" />
        </UpdateParameters>

        <InsertParameters>
            <asp:Parameter Name="Nama_Pengadu" Type="String" />
            <asp:Parameter Name="IC_Pengadu" Type="Int64" />
            <asp:Parameter Name="Tarikh_Aduan" Type="String" />
            <asp:Parameter Name="Tel_Pengadu" Type="String" />
            <asp:Parameter Name="Zon_Payphone" Type="String" />
            <asp:Parameter Name="Kwsn_Payphone" Type="String" />
            <asp:Parameter Name="No_Tel_Payphone" Type="String" />
            <asp:Parameter Name="Aduan_Payphone" Type="String" />
            <asp:Parameter Name="Negeri" Type="String" />
            <asp:Parameter Name="Status" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>

</asp:Content>

Last edited by jlandan2; August 10th, 2013 at 09:46 PM..
Reply With Quote
  #10 (permalink)  
Old August 11th, 2013, 06: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

As far as I can see, this should work fine. When you say:

Quote:
But it doesnt run. In your coding, u wrote SelectedValue='<%# Bind("Title") %>', but when i wrote it in my coding, there is no SelectedValue Property..
what do you mean exactly? What does "doesn't run" mean? Do you get an error? If so, in VS or in the browser? And what does "there is no SelectedValue Property" mean? Again, do you get an error or does it just now show up in IntelliSense?

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
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 01:05 PM.


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