Results 1 to 8 of 8

Thread: Trouble getting dropdownlist value

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    Trouble getting dropdownlist value

    Using asp.net, I have a form with a dropdownlist that is populated onload. I do this by binding to a datareapter. My first question is how can I add value and text to the dropdown with binding. I see you can do this by ListItem.Value but is there an easy solution?

    My other issue is that my value that comes back is always the first item in my list?

    Need some help.

    VB Code:
    1. <%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" Trace="false" debug="true"%>
    2. <%@ import Namespace="System.Data.SqlClient" %>
    3. <%@ Import Namespace="System.Data" %>
    4. <%@ Import Namespace="System.IO" %>
    5.  
    6. <script runat="server">
    7.  
    8.     Sub Add_Info(s As Object, e as EventArgs)
    9.         lblMsg.Text = drpManufacturer.SelectedValue
    10.     End Sub
    11.    
    12.     Sub Page_Load
    13.    
    14.             Dim conPubs as SqlConnection
    15.             Dim cmdSQL as SqlCommand
    16.             Dim dtrAllProducts as SqlDataReader
    17.            
    18.             'Retrieve records from database
    19.             conPubs = New SqlConnection("Server=xx.xx.xx.xx;uid=name;pwd=pwd;database=db")
    20.             cmdSQL = New SqlCommand("SELECT * FROM why3s_products", conPubs)
    21.             conPubs.Open()
    22.             dtrAllProducts = cmdSQL.ExecuteReader()
    23.                        
    24.             'Bind to Repeater
    25.             rptPrdList.DataSource = dtrAllProducts
    26.             rptPrdList.DataBind()
    27.                        
    28.             dtrAllProducts.Close()
    29.             conPubs.Close()
    30.  
    31.             'Retrieve records from database
    32.             conPubs = New SqlConnection("Server=xx.xx.xx.xx;uid=name;pwd=pwd;database=db")
    33.             cmdSQL = New SqlCommand("SELECT manufacturers_name FROM why3s_manufacturers", conPubs)
    34.             conPubs.Open()
    35.             dtrAllProducts = cmdSQL.ExecuteReader()
    36.                                    
    37.             'Bind to DropDownList
    38.             drpManufacturer.DataSource = dtrAllProducts
    39.             drpManufacturer.DataTextField = "manufacturers_name"
    40.             drpManufacturer.DataBind()
    41.            
    42.             dtrAllProducts.Close()
    43.             conPubs.Close()
    44.     End Sub
    45.  
    46. </script>
    47. <html>
    48. <head>
    49.     <title>Add New Manufacturer</title>
    50.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    51. </head>
    52. <body>
    53.     <form id="frmAdd" name="frmAdd" action="addproduct.aspx" method="post" enctype="multipart/form-data" runat="server">
    54.     <!--#include file="inc_top_menu.aspx" --><br>
    55.  
    56.         <table cellspacing="0" cellpadding="0" width="750" border="0">
    57.             <tbody>
    58.                 <tr>
    59.                    
    60.         <td width="125" valign="top"> <asp:validationsummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" HeaderText="Missing:" DisplayMode="List"></asp:validationsummary>
    61.         </td>
    62.                     <td width="625">
    63.                         <table cellspacing="2" cellpadding="0" width="100%" border="0">
    64.             <tbody>
    65.              <tr>
    66.                 <td>Manufacturer:</td>
    67.                 <td><asp:dropdownlist ID="drpManufacturer" runat="server"></asp:dropdownlist>
    68.                   - <em><font size="2" face="Verdana, Arial, Helvetica, sans-serif">If
    69.                   not in list please create before you continue.</font></em></td>
    70.               </tr>
    71.               <tr>
    72.                 <td width="26%"> Product Model Name:</td>
    73.                 <td width="74%"> <asp:textbox id="txtModel" runat="server" TextMode="SingleLine" MaxLength="15"></asp:textbox> <asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" Text="Required" ErrorMessage="Model Name" ControlToValidate="txtModel"></asp:requiredfieldvalidator> </td>
    74.               </tr>
    75.               <tr>
    76.                 <td>Product Fullmodel Name:</td>
    77.                 <td><asp:textbox AutoPostBack="false" ID="txtFullModel" MaxLength="60" runat="server" /> <asp:requiredfieldvalidator ControlToValidate="txtFullModel" ErrorMessage="Fullmodel Name" Text="Required" runat="server" /> </td>
    78.               </tr>
    79.               <tr>
    80.                 <td> Product Image:</td>
    81.                 <td><input name="inpFileUpload" type="file" id="inpFileUpload" size="40" maxlength="60"  Runat="Server">
    82.                   <font size="1" face="Verdana, Arial, Helvetica, sans-serif"><em>300kb
    83.                   max file size.</em></font></td>
    84.               </tr>
    85.               <tr>
    86.                 <td> Product Description</td>
    87.                 <td> <asp:textbox id="txtDescription" runat="server" TextMode="SingleLine" MaxLength="255" Columns="50"></asp:textbox> <asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" Text="Required" ErrorMessage="Description" ControlToValidate="txtDescription"></asp:requiredfieldvalidator> </td>
    88.               </tr>
    89.               <tr>
    90.                 <td>Product Price:</td>
    91.                 <td><asp:textbox ID="txtPrice" MaxLength="10" runat="server" /> <asp:requiredfieldvalidator ControlToValidate="txtPrice" ErrorMessage="Price" InitialValue="Required" runat="server" Text="Required" /> </td>
    92.               </tr>
    93.               <tr>
    94.                 <td>Product Retail Price:</td>
    95.                 <td><asp:textbox ID="txtRetail" MaxLength="10" runat="server" /></td>
    96.               </tr>
    97.               <tr>
    98.                 <td>Product Cost:</td>
    99.                 <td><asp:textbox ID="txtCost" MaxLength="10" runat="server" /></td>
    100.               </tr>
    101.               <tr>
    102.                 <td>Product Wholesale Price:</td>
    103.                 <td><asp:textbox ID="txtWholesale" MaxLength="10" runat="server" /></td>
    104.               </tr>
    105.               <tr>
    106.                 <td>Product Weight:</td>
    107.                 <td><asp:textbox ID="txtWeight" MaxLength="7" runat="server" /></td>
    108.               </tr>
    109.               <tr>
    110.                 <td>Product Status:</td>
    111.                 <td><div align="left">
    112.                     <asp:dropdownlist ID="drpStatus" runat="server">
    113.                     <asp:listitem Text="Show" runat="server"></asp:listitem>
    114.                     <asp:listitem Text="Hide" runat="server"></asp:listitem>
    115.                     </asp:dropdownlist>
    116.                     <em><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Display
    117.                     vacuum on page.</font></em></div></td>
    118.               </tr>
    119.               <tr>
    120.                 <td>Product Sold-To-Dt:</td>
    121.                 <td><asp:textbox ID="txtSTD" MaxLength="4" runat="server" Text="0" /> <asp:requiredfieldvalidator ControlToValidate="txtSTD" ErrorMessage="Sold-To-Date" InitialValue="Required" Text="Required" runat="server" /> </td>
    122.               </tr>
    123.               <tr>
    124.                 <td>Product Show Button:</td>
    125.                 <td><asp:dropdownlist ID="drpShowBuy" runat="server">
    126.                     <asp:listitem Text="Show" runat="server"></asp:listitem>
    127.                     <asp:listitem Text="Hide" runat="server"></asp:listitem>
    128.                     </asp:dropdownlist> <em><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Do
    129.                   not display the buy button.</font></em></td>
    130.               </tr>
    131.               <tr>
    132.                 <td>Product Special Notify:</td>
    133.                 <td><asp:textbox ID="txtSpecialNotify" MaxLength="55" runat="server" /></td>
    134.               </tr>
    135.                <tr>
    136.                 <td>Product Quantity:</td>
    137.                 <td><asp:textbox ID="txtQuantity" MaxLength="4" runat="server" Text="0" /></td>
    138.               </tr>
    139.               <tr>
    140.                 <td>&nbsp;</td>
    141.                 <td><asp:button ID="butAdd" OnClick="Add_Info" runat="server" Text="Add" BackColor="Yellow" BorderColor="Blue" BorderStyle="Groove"></asp:button> <asp:label ID="lblError" runat="server"></asp:label></td>
    142.               </tr>
    143.               <tr>
    144.                 <td>&nbsp;</td>
    145.                 <td><asp:label ID="lblMsg" runat="server"></asp:label></td>
    146.               </tr>
    147.              
    148.             </tbody>
    149.           </table>
    150.                     </td>
    151.                 </tr>
    152.             </tbody>
    153.         </table>
    154.         </form>
    155.     <br />
    156.     <center>
    157.     <asp:repeater EnableViewState="false" ID="rptPrdList" runat="server">
    158.         <headertemplate>
    159.             <table border="1">
    160.                 <tr>
    161.                     <th>ID</th>
    162.                     <th>Name</th>
    163.                     <th>Image</th>
    164.                     <th>Entry_Dt</th>
    165.                     <th>Description</th>
    166.                 </tr>
    167.         </headertemplate>
    168.        
    169.         <itemtemplate>
    170.             <tr bgcolor="#CCFFFF">
    171.                
    172.           <td><a href="updatemanufacturer.aspx?ID=<%# Container.DataItem("manufacturers_id") %>"><%# Container.DataItem("manufacturers_id") %></a></td>
    173.                 <td><%# Container.DataItem("manufacturers_name") %></td>
    174.                 <td><%# Container.DataItem("manufacturers_image") %></td>
    175.                 <td><%# Container.DataItem("manufacturers_entry_dt") %></td>
    176.                 <td><%# Container.DataItem("manufacturers_description") %></td>
    177.             </tr>
    178.         </itemtemplate>
    179.        
    180.         <AlternatingItemTemplate>
    181.             <tr bgcolor="#99FF66">
    182.                 <td><%# Container.DataItem("manufacturers_id") %></td>
    183.                 <td><%# Container.DataItem("manufacturers_name") %></td>
    184.                 <td><%# Container.DataItem("manufacturers_image") %></td>
    185.                 <td><%# Container.DataItem("manufacturers_entry_dt") %></td>
    186.                 <td><%# Container.DataItem("manufacturers_description") %></td>
    187.             </tr>
    188.         </AlternatingItemTemplate>
    189.        
    190.         <footertemplate>
    191.             </table>
    192.         </footertemplate>
    193.     </asp:repeater>
    194.     </center>
    195. </body>
    196. </html>

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    1)
    Set the DataTextField for the text to display.
    Set the DataValueField for the value for that text.

    2) You need to check of the PostBack

    VB Code:
    1. If Not Page.IsPostBack
    2.    'Do this code if the page isn't posted back
    3. End If

    3) Why are you creating 2 connections in the Page_Load event?
    Try something like this

    VB Code:
    1. Sub Page_Load
    2.    
    3.    Dim conPubs as SqlConnection
    4.    Dim cmdProducts as SqlCommand
    5.    Dim cmdManufacturers as SqlCommand
    6.    Dim dtrAllProducts as SqlDataReader
    7.    Dim dtrAllManufacturers As SqlDataReader
    8.            
    9.    'Retrieve records from database
    10.    conPubs = New SqlConnection("Server=xx.xx.xx.xx;uid=name;pwd=pwd;database=db")
    11.  
    12.    cmdProducts = New SqlCommand("SELECT * FROM why3s_products", conPubs)
    13.    cmdManufacturers = New SqlCommand("SELECT manufacturers_name FROM why3s_manufacturers", conPubs)
    14.  
    15.    Try
    16.       conPubs.Open()
    17.       dtrAllProducts = cmdProducts.ExecuteReader()
    18.       dtrAllManufacturers = cmdManufacturers.ExecuteReader()
    19.                
    20.       'Bind to Products to Repeater
    21.       rptPrdList.DataSource = dtrAllProducts
    22.       rptPrdList.DataBind()
    23.  
    24.       'Bind to DropDownList
    25.       drpManufacturer.DataSource = dtrAllManufacturers
    26.       drpManufacturer.DataTextField = "manufacturers_name"
    27.       drpManufacturer.DataValueField = "manufacturers_ID"
    28.       drpManufacturer.DataBind()
    29.                        
    30.       dtrAllProducts.Close()
    31.       dtrManufacturers.Close()
    32.  
    33.       conPubs.Close()
    34.    
    35.    Catch ex As Exception
    36.       Response.write("Error Occurred: " & ex.Message & "<br>" & ex.StackTrace)
    37.    End Try
    38.  
    39. End Sub
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830
    Thanks for the quick response.

    I changed to 1 connection but get the following at the top of my page:

    Error Occurred: There is already an open DataReader associated with this Connection which must be closed first. ......

    This points to the following line:
    dtrAllManufacturers = cmdManufacturers.ExecuteReader()

    Setting the DataValueField does make sense now.

    I am very new to asp.net. Is the Try, Catch ex As Exception the new On Error?

    Thanks again for your help.

  4. #4
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    okay, open the first reader, process the data, close the reader, then do the same with the second reader.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830
    Yes, this does work.

    My other issue is I can't get the value selected to return.

    Is it due to the IsPostBack? I have this in a On_Click event so does the Page_Load reset my selection?

    VB Code:
    1. <%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" Trace="false" debug="true"%>
    2. <%@ import Namespace="System.Data.SqlClient" %>
    3. <%@ Import Namespace="System.Data" %>
    4. <%@ Import Namespace="System.IO" %>
    5.  
    6. <script runat="server">
    7.  
    8.     Sub Add_Info(s As Object, e as EventArgs)
    9.             If IsValid Then
    10.                    'Query db to see if product is found if not then insert new record.
    11.                    Dim conPubs as SqlConnection
    12.                    Dim sSQL as SqlCommand
    13.        Dim sTmpSQL as String
    14.                    Dim sInsertSQL as String
    15.                    Dim cmdInsertSQL as SqlCommand
    16.                    Dim dtrUsers as SqlDataReader
    17.                    Dim iFoundPrds as Integer
    18.                    Dim iInsertCnt as Integer
    19.        Dim sFileName as String
    20.        Dim sFullImagePath as String
    21.        Dim sFolder as String
    22.        Dim sImageSize as String
    23.    
    24.     'Get the name of the file posted
    25.     sFileName = inpFileUpload.PostedFile.Filename
    26.     'In bytes 29.9 KB (30,704 bytes)
    27.     'Don't want to allow more then 307,200 bytes
    28.     sImageSize = inpFileUpload.PostedFile.ContentLength
    29.     sFileName = Path.GetFileName(sFileName)                         sFolder = "C:\websites\dir1\dir2\site.com\images\"
    30.                    
    31.                     'Determine if an image is sent.
    32.                     If Len(sFileName) > 0 Then
    33.                         If sImageSize <= 307200 Then
    34.                             sFullImagePath = "images\" & sFileName
    35.                         End if
    36.                     End if 
    37.                    
    38.                     'Create the directory if it does not exist
    39.                     If (not Directory.Exists(sFolder)) Then
    40.                         Directory.CreateDirectory(sFolder)
    41.                     End if
    42.                    
    43.                     iInsertCnt = 0
    44.                    conPubs = New SqlConnection("Server=xx.xx.xx.xx;uid=name;pwd=pwd;database=dbname")
    45.                    conPubs.Open()
    46.                    sTmpSQL = "SELECT count(*) as ProductsFound FROM why3s_products where UPPER(RTRIM(products_model)) = '" & UCase(txtModel.Text) & "' AND manufacturers_id = 1"
    47.                    lblMsg.Text = sTmpSQL
    48.                    sSQL = New SqlCommand(sTmpSQL, conPubs)
    49.                    dtrUsers = sSQL.ExecuteReader()
    50.                    While dtrUsers.Read()
    51.                        iFoundPrds = dtrUsers("ProductsFound")
    52.                    End While
    53.                    dtrUsers.Close()
    54.                    If iFoundPrds = 0 Then
    55.                        'lblError.Text = "No users found"
    56.                        sInsertSQL = "INSERT INTO why3s_products (products_quantity, products_model, products_fullmodel, products_image, products_price, products_retail_price, products_cost, products_wholesale_price, products_entry_dt, products_last_change_dt, products_weight, products_status, products_sold_to_dt, products_description, products_show_buy, products_special_notify, manufacturers_id) values (" & txtQuantity.Text & ", '" & txtModel.Text & "', '" & txtFullModel.Text & "', '" & sFullImagePath & "', " & txtPrice.Text & ", " & txtRetail.Text & ", " & txtCost.Text & ", " & txtWholesale.Text & ", getdate(), getdate(), " & txtWeight.Text & ", 0, " & txtSTD.Text & ", '" & txtDescription.Text & "', 1, '" & txtSpecialNotify.Text & "', 1)"
    57.                        cmdInsertSQL = New SqlCommand(sInsertSQL, conPubs)
    58.                        iInsertCnt = cmdInsertSQL.ExecuteNonQuery()
    59.                        'lblMsg.Text = "You have inserted " & iInsertCnt & " records."
    60.                        
    61.                        If Len(sFileName) > 0 Then
    62.                             'Check to see if file already exists
    63.                             If File.Exists(sFolder & sFileName)
    64.                                 'Only save if file is less then 300kb
    65.                                 If sImageSize <= 307200 Then
    66.                                     'Save file to server
    67.                                     inpFileUpload.PostedFile.SaveAs(sFolder & sFileName)                               
    68.                                 End if
    69.                             End if
    70.                        End if
    71.                    Else
    72.                        'lblError.Text = iFoundUsers & " users found."
    73.                        'lblMsg.Text = "User already found.  Please try again."
    74.                    End iF
    75.                    conPubs.Close()
    76.                    'If iInsertCnt > 0 Then
    77.                     'Response.Redirect("addproduct.aspx")
    78.                    'End if
    79.             Else
    80.                 'lblError.Text = "Not IsValid"
    81.                    lblMsg.Text = vbNullString
    82.             End if
    83.     End Sub
    84.    
    85.     Sub Page_Load
    86.  
    87.             Dim conPubs as SqlConnection
    88.             Dim cmdProducts as SqlCommand
    89.             Dim cmdManufacturers as SqlCommand
    90.             Dim dtrAllProducts as SqlDataReader
    91.             Dim dtrAllManufacturers as SqlDataReader
    92.            
    93.             'Retrieve records from database
    94.             conPubs = New SqlConnection("Server=xx.xx.xx.xx;uid=name;pwd=pwd;database=dbname")
    95.             cmdProducts = New SqlCommand("SELECT * FROM why3s_products", conPubs)
    96.             cmdManufacturers = New SqlCommand("SELECT manufacturers_name, manufacturers_id FROM why3s_manufacturers", conPubs)
    97.            
    98.     'Try
    99.         conPubs.Open()
    100.                
    101.                 dtrAllProducts = cmdProducts.ExecuteReader()
    102.                                        
    103.                 'Bind Manufacturer to Repeater
    104.                 rptPrdList.DataSource = dtrAllProducts
    105.                 rptPrdList.DataBind()
    106.                 dtrAllProducts.Close()
    107.        
    108.                 dtrAllManufacturers = cmdManufacturers.ExecuteReader()
    109.            
    110.                 'Bind to DropDownList
    111.                 drpManufacturer.DataSource = dtrAllManufacturers
    112.                 drpManufacturer.DataTextField = "manufacturers_name"
    113.                 drpManufacturer.DataValueField = "manufacturers_id"
    114.                 drpManufacturer.DataBind()
    115.                
    116.                 dtrAllManufacturers.Close()
    117.    
    118.                 conPubs.Close()
    119.            
    120.             'Catch ex As Exception
    121.                 'Response.Write("Error Occurred: " & ex.Message & "<br>" & ex.StackTrace)
    122.             'End Try
    123.     End Sub
    124.  
    125. </script>
    126. <html>
    127. <head>
    128.     <title>Add New Manufacturer</title>
    129.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    130. </head>
    131. <body>
    132.     <form id="frmAdd" name="frmAdd" action="addproduct.aspx" method="post" enctype="multipart/form-data" runat="server">
    133.     <!--#include file="inc_top_menu.aspx" --><br>
    134.  
    135.         <table cellspacing="0" cellpadding="0" width="750" border="0">
    136.             <tbody>
    137.                 <tr>
    138.                    
    139.         <td width="125" valign="top"> <asp:validationsummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" HeaderText="Missing:" DisplayMode="List"></asp:validationsummary>
    140.         </td>
    141.                     <td width="625">
    142.                         <table cellspacing="2" cellpadding="0" width="100%" border="0">
    143.             <tbody>
    144.              <tr>
    145.                 <td>Manufacturer:</td>
    146.                 <td><asp:dropdownlist ID="drpManufacturer" runat="server"></asp:dropdownlist>
    147.                   - <em><font size="2" face="Verdana, Arial, Helvetica, sans-serif">If
    148.                   not in list please create before you continue.</font></em></td>
    149.               </tr>
    150.               <tr>
    151.                 <td width="26%"> Product Model Name:</td>
    152.                 <td width="74%"> <asp:textbox id="txtModel" runat="server" TextMode="SingleLine" MaxLength="15"></asp:textbox> <asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" Text="Required" ErrorMessage="Model Name" ControlToValidate="txtModel"></asp:requiredfieldvalidator> </td>
    153.               </tr>
    154.               <tr>
    155.                 <td>Product Fullmodel Name:</td>
    156.                 <td><asp:textbox AutoPostBack="false" ID="txtFullModel" MaxLength="60" runat="server" /> <asp:requiredfieldvalidator ControlToValidate="txtFullModel" ErrorMessage="Fullmodel Name" Text="Required" runat="server" /> </td>
    157.               </tr>
    158.               <tr>
    159.                 <td> Product Image:</td>
    160.                 <td><input name="inpFileUpload" type="file" id="inpFileUpload" size="40" maxlength="60"  Runat="Server">
    161.                   <font size="1" face="Verdana, Arial, Helvetica, sans-serif"><em>300kb
    162.                   max file size.</em></font></td>
    163.               </tr>
    164. '...... REMOVE CODE TO SHORTEN
    165.                            
    166.               <tr>
    167.                 <td>&nbsp;</td>
    168.                 <td><asp:button ID="butAdd" OnClick="Add_Info" runat="server" Text="Add" BackColor="Yellow" BorderColor="Blue" BorderStyle="Groove"></asp:button> <asp:label ID="lblError" runat="server"></asp:label></td>
    169.               </tr>
    170.               <tr>
    171.                 <td>&nbsp;</td>
    172.                 <td><asp:label ID="lblMsg" runat="server"></asp:label></td>
    173.               </tr>
    174.              
    175.             </tbody>
    176.           </table>
    177.                     </td>
    178.                 </tr>
    179.             </tbody>
    180.         </table>
    181.         </form>
    182.     <br />
    183.     <center>
    184.     <asp:repeater EnableViewState="false" ID="rptPrdList" runat="server">
    185.         <headertemplate>
    186.             <table border="1">
    187.                 <tr>
    188.                     <th>ID</th>
    189.                     <th>Model</th>
    190.                                 <th>Manufacturers ID</th>
    191.                 </tr>
    192.         </headertemplate>
    193.        
    194.         <itemtemplate>
    195.             <tr bgcolor="#CCFFFF">
    196.                 <td><a href="updateproduct.aspx?ID=<%# Container.DataItem("products_id") %>"><%# Container.DataItem("products_id") %></a></td>
    197. 'REMOVED CODE TO FIT
    198.                 <td><%# Container.DataItem("manufacturers_id") %></td>
    199.             </tr>
    200.         </itemtemplate>
    201.        
    202.         <AlternatingItemTemplate>
    203.             <tr bgcolor="#99FF66">
    204.         <td><a href="updateproduct.aspx?ID=<%# Container.DataItem("products_id") %>"><%# Container.DataItem("products_id") %></a></td>
    205. 'REMOVED CODE TO FIT
    206.                 <td><%# Container.DataItem("products_model") %></td>
    207.                             <td><%# Container.DataItem("manufacturers_id") %></td>          </tr>
    208.         </AlternatingItemTemplate>
    209.        
    210.         <footertemplate>
    211.             </table>
    212.         </footertemplate>
    213.     </asp:repeater>
    214.     </center>
    215. </body>
    216. </html>

  6. #6
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Where are you trying to retrieve it at???
    VB Code:
    1. Dim ManufacturerID As Integer
    2.  
    3. ManufacturerID = drpManufacturer.SelectedValue
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830
    Well, I did find out that it only works if I do a 'Not IsPostBack' on my On_Load. It must be reloading the form then doing the Button On_CLick.

    Is it possible to run my on_click code then refresh the page?

    This doesn't really relate to this subject but you seem to have an extremely good handle on .net. When working with forms do you have a function after a users clicks and submits your data that resets the form to the original state or is there code that does this for you?

    Thanks again for all your help.

  8. #8
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    You could set the "EnableViewState" property to "False" on all the controls that have that property.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width