Edit ads RRS feed

  • Question

  • User-891577769 posted

    How on EditAd.aspx page ad new DropDownList and CheckBox  and select value which is in Database.

    Note, DropDownList and CheckBox  I have aded before on PostAd.aspx page and enter its value in Database.

    Wednesday, November 12, 2008 6:35 AM

All replies

  • User730446648 posted

    For the update page the codebehind is not used for binding.
    Instead all the binding is done on the aspx page.

    You need to enter your binding name exactly like you entered into the database.

    Here's a sample:

    <asp:CheckBox ID="CeramicTileCB" runat="server" Text="&nbsp;Ceramic Tile" Checked='<%# Bind("CeramicTile") %>' /><br />

    Note that on the checkbox you use checked, and on the dropdown you use text.

    And scroll to the bottom of the page, and you will see the final step, just copy how the other entries are done.


    If you add a new textbox entry in the future and you make it not allow database null.
    Then you will need to make sure you use the default value if a user edits it and removes the entry.


    And that's it.


    Wednesday, November 12, 2008 11:36 AM
  • User-891577769 posted

    OK, thanks,


    How on EditAd.aspx page set that entries of empty TextBox, in Database not have "NULL" value than only empty fields

    Thursday, November 13, 2008 5:29 AM
  • User-891577769 posted

    I forgottoerite in previously reply, your advise work OK, but


     1. What code and file I have to change that can edit new entry CeramicCheckBox and new CeramicDropDownList , because I try and return error:

    ObjectDataSource 'AdDataSource' could not find a non-generic method 'UpdateAd' that has parameters:

    CeramicCheckBox, CeramicDropDownList

    2. How that new entry not have NULL value in Database if it is empty, than should be only empty value.?

    3. How on ShowAd.aspx page show new value if not empty field in Database (entries from CheckBox, DropDownList and TextBox), and if is empty then nothing show?


    Thursday, November 13, 2008 6:06 PM
  • User730446648 posted

    If this doesn't work show me a code sample of what you are trying to add.

    For my sample "CeramicTile" CeramicTile is a name of a column in my database that I added.

    If you added a column named abc123 you need to change CeramicTile to abc123.

    If you got that right and it's still having an error, you didn't change the code at the bottom of editad.aspx

    It says something like controlparameter
    and it specifies a control id.

    This control id is the id name of the control in my case the checkbox was CeramicTileCB.


    2. How that new entry not have NULL value in Database if it is empty, than should be only empty value.?



    When you're in the control parameter you will also see default value=  


    On the showad page you need to write an if statement on the codebehind.

    So for example I used labels as the text for the checkboxes.

    If ad.checkbox1 = True Then

    Label1.text = "something to write here."


    Label1.text = ""

    End If


    You could also use a        .visable = true           or false.


    Let me know if you need anymore help.

    Good Luck


    Thursday, November 13, 2008 10:46 PM
  • User-891577769 posted

    in 3. quesation

    On ShowAd.aspx.CS (codebehind) u whics section  write an if statement on the , I trayed in PageLoad andbut do not work, return error somethin like

    ..." ad.checkbox1 is not in current content..."

    Sunday, November 16, 2008 6:08 AM
  • User730446648 posted

    Look for the following code and place your if statement just below this code.


    Protected Sub AdDetails_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)

    Dim item As RepeaterItem = e.Item

    Dim ad As AdsDataComponent.AdsRow = CType(item.DataItem, AdsDataComponent.AdsRow)

    If Not (ad Is Nothing) Then


    Sunday, November 16, 2008 11:00 AM
  • User-891577769 posted

    - How remove caracter "$"  beside price  in PriceLabel  on ShowAd.aspx  page, I will write the price without "$".


     - How on EditAd.aspx page set AdType RadioButton to alow user tahat edit ad type (for sale or wanted).

    I try but return error. ( I use raither C# ).

    Thursday, November 20, 2008 9:26 AM
  • User730446648 posted

    There's a couple different options.

    The easiest is just change the c to an f

    AdPriceLabel.Text = String.Format("{0:f}", ad.Price)

    That quick fix gets removes the currency, and leaves the decimal, but it will not add a comma. (1,295.95)

    If you need a comma, let me know and I'll show you a fix for that.


    I use VB, but try this converter for any vb  code you would like to try.



    Friday, November 21, 2008 10:30 AM
  • User-891577769 posted

    1. Question:  Yes, a want to add a comma in price (without $) and that should be in format 1.000,00


     2. Question: - How on EditAd.aspx page add AdType RadioButton to alow user that edit ad type (for sale or wanted).

    Sunday, November 23, 2008 5:48 AM
  • User730446648 posted

    I'm assuming that you got the comma and decimal backwards?

    If you didn't, I have no idea how to get it to display like that.

    But try this for results like this, 1,000.00
    Replace the other AdPriceLabel.text =  . . . . .
    with the following.

    Dim nfi As System.Globalization.NumberFormatInfo = New System.Globalization.NumberFormatInfo

    nfi.CurrencyDecimalDigits = 2

    nfi.CurrencySymbol = ""

    AdPriceLabel.Text = String.Format(nfi, "{0:c}", ad.Price)

    And this for your radio button on the edit ad page

    <asp:RadioButtonList ID="AdTypeSelection" Text='<%# Bind("AdType") %>'

    runat="server" RepeatDirection="Horizontal" Width="300" RepeatLayout="Flow">

    asp:ListItem Value="1"> This is one of my radio selections </asp:ListItem>
    <asp:ListItem Value="2"> This is another radio selections </asp:ListItem>
    <asp:ListItem Value="3"> This is my last radio selections </asp:ListItem>



    And that should work.


    Sunday, November 23, 2008 10:33 AM