Does datalist tag need to be bind on serverside when not using database - sql

I have a few lines of code in which no server connection and databse fetching included. Problem is picture is not being displayed when I want to show that in datalist.
<asp:DataList ID="dlpic" runat="server" RepeatDirection="Horizontal" RepeatColumns = "4">
<ItemTemplate>
<div class="item" id="construction">
<div class="border">
<a id="imageLink" href="~/images/Gallery/Gallery_Halmar001.jpg" class="zoom prettyPhoto" runat="server" >
<img src="images/Gallery/Gallery_Halmar001.jpg" class="scale-with-grid" />
</a>
</div>
<h5></h5>
<p></p>
<div class="shadow"></div>
</div>
</ItemTemplate>
</asp:DataList>
Do I still need to bind datalist?

Yes you need to bind it. A datalist will not render any items if it is unbound or bound to a List with 0 items. But if you're not binding to anything, why use the datalist at all? Just display the markup directly.

Related

Count items in datasource or inside repeater

I found some other questions about this argument but I can't get anything to work.
I have a repeater with datasource, this is my repeater code:
<div class="container dafareoggi" id="divDaFareOggi">
<div runat="server" id="divSegnaposto"></div>
<asp:Repeater runat="server" ID="rptDaFareOggi" DataSourceID="SqlAttivitaDaFareOggi">
<ItemTemplate>
<div id="<%# Eval("id") %>">
<div class="div-titolo" title="<%# Eval("Titolo") %>"><%# Eval("Titolo") %></div>
<div class="div-testo" title="<%# Eval("Note") %>"><%# Eval("Note") %></div>
<div>
<table style="width: 100%;margin-top:0.5em;padding-right:0.2em;">
<tr>
<td style="width: 50%; text-align: left;">
<asp:ImageButton runat="server" ImageUrl="~/images/gabri.png" Width="2.3em" Height="2.3em" ToolTip='<%#Eval("tecnico")%>' Enabled="false" Visible='<%# IIf(Eval("idutente") = 8, True, False) %>'/>
<asp:ImageButton runat="server" ImageUrl="~/images/giuse.png" Width="2.3em" Height="2.3em" ToolTip='<%#Eval("tecnico")%>' Enabled="false" Visible='<%# IIf(Eval("idutente") = 2, True, False) %>'/>
<asp:ImageButton runat="server" ImageUrl="~/images/robi.png" Width="2.3em" Height="2.3em" ToolTip='<%#Eval("tecnico")%>' Enabled="false" Visible='<%# IIf(Eval("idutente") = 5, True, False) %>'/>
</td>
<td style="width: 50%; text-align: right; ">
<asp:LinkButton CommandName="delAttivita" CommandArgument='<%#Eval("ID")%>' runat="server" ID="lnkDelAtt" CausesValidation="False" OnClientClick="return confirm('Sei sicuro di voler eliminare questa attivita?');"><i class="fa fa-trash fa-lg" title="Elimina attività"></i></asp:LinkButton>
<asp:LinkButton CommandName="editAttivita" CommandArgument='<%#Eval("ID")%>' runat="server" ID="lnkEditAtt"><i class="fa fa-pencil-square fa-lg" title="Modifica attività"></i></asp:LinkButton>
</td>
</tr>
</table>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
In the repeater there is a place card div with id divSegnaposto (2nd row) and then a bunch of div may be loaded accordingly to data read from the db.
What I want is that when there are no data to load, so divSegnaposto is the only item, to show it and, vice versa, when there are 1 ore more other divs, to hide it.
I figure that I should count the number of items inside the repeater or rows inside datasouce (I'm using EF), so I tried different approach in repeater_databound_event, but for example repeater.items.count is always 0.
How can I achieve the goal?
I ended up using a linq query that gets the same as the sqldatasource at itembound event and then I check if it's empty or not and show\hide the placecard accordingly. I don't like it too much because makes me mad: I already have all the information I need inside the repeater or the sql data source, so I guess I thought there was an easier, less code-consuming way to do it. But all the answers I found are more complicated than just re-do the query in code behind...

Images are not displaying in asp.net webforms

I have image links of a website's images stored in my DB but when I show them on my asp page using repeater or data list which im building, it shows some where pics and somewhere just boxes and no
image, can anyone help me?
here is my datalist code to show products but some images are being shown and some are like broken icons and empty box having no image, and i have image links of a website which i am displaying in
data list and i have checked all links as well on web they work perfectly fine but don't show anything in my data list web form,is this a styling issue or binding?
code of Data list is given below
<div style=" border:inset; margin-left:100px; display:inline-block;">
<asp:DataList ID="DataList1" runat="server" RepeatColumns="5" RepeatDirection="Horizontal">
<ItemTemplate>
<div class="span4" style="display:inline-block; border-top:1px; background-color:none;width:190px; height:440px; border:solid; border-width:1px; border-spacing:2px 4px; border-bottom:inset; border-top-width:1px;" runat="server"><br />
<div class="products" style="height:430px; width:189x; border:inset;border-style:none;border-spacing:2px 4px;">
<asp:Image ID="ImgId" runat="server" style=" height:160px; width:160px;" ImageUrl='<%#(DataBinder.Eval(Container.DataItem,"ImageLink")) %>' /> <br />
<h3 class="title" style="font-family:Pristina;font-size:medium;height:30px; margin-bottom:-15px;"> <b><%# Eval("Name") %></b><br /><br /><br /></h3>
<br />
<p class="price" style="font-family:Pristina;font-size:medium; height:30px;padding-top:40px; "><b>Price</b> <%# Eval("Price") %> <br /><br /><br /><br /><br /></p><br />
<br />
<b style="margin-bottom:-20px">www.shophive.com</b>
</div>
</div>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Top"/>
</asp:DataList>
</div>

How to change autocompleter widget size

I tried the code from the project to change the size of the select box:
<strong>Result Div :</strong>
<div id="formResult" class="result ui-widget-content ui-corner-all">Submit form bellow.</div>
<strong>Topics Div :</strong>
<div id="topics" class="result ui-widget-content ui-corner-all"></div>
<s:form id="form" action="echo" theme="simple" cssClass="yform">
<fieldset>
<legend>Select Box as Autocompleter</legend>
<div class="type-select">
<label for="echo">Echo: </label>
<sj:autocompleter
id="customers"
name="echo"
list="%{customers}"
listValue="name"
listKey="id"
selectBox="true"
selectBoxIcon="true"
onChangeTopics="autocompleteChange"
onFocusTopics="autocompleteFocus"
onSelectTopics="autocompleteSelect"
cssStyle="width:100%;"
/>
</div>
<div>
<sj:submit
targets="formResult"
value="AJAX Submit"
indicator="indicator"
button="true"
/>
<img id="indicator" src="images/indicator.gif" alt="Loading..." style="display:none"/>
</div>
</fieldset>
</s:form>
<br/>
but it doesn't work. I don't know what is the problem with this code.
Looking at generated HTML neither cssStyle nor cssClass of <sj:autocompleter> tag is set to actual input field. But you can use plain CSS to style this input field. Put your <sj:autocompleter> inside of some element to change only specific input then you can use something like that:
.type-select .s2j-combobox-input {
width: 100%;
}
Where type-select is class of wrapper element and s2j-combobox-input is the class of generated input field for the <sj:autocompleter>.

Can't get Cucumber/Capybara to find radio buttons

I'm having trouble getting Cucumber to "choose" a radio button and hoping someone can give me a sanity check. Without quoting a huge mass of HTML junk, here's the relevant portion (which I collected from print.html). It's within a modal div that is activated by a button. I can "click" that button and see the modal window appear (I'm running it as a #javascript scenario in Selenium).
<div class="modal-body pagination-centered">
<img src="/assets/payment.png" alt="Payment" />
<form novalidate="novalidate" method="post" id="edit_cart_1" class="simple_form edit_cart" action="/carts/complete" accept-charset="UTF-8">
<div style="margin:0;padding:0;display:inline">
<input type="hidden" value="✓" name="utf8" />
<input type="hidden" value="put" name="_method" />
</div>
<div class="control-group hidden cart_property_id">
<div class="controls">
<input type="hidden" name="cart[property_id]" id="cart_property_id" class="hidden" />
</div>
</div>
<div id="payment_fat_buttons" class="fat-buttons">
<div class="vertical-button-wrapper">
<input type="radio" value="cash" name="cart[payment_type]" id="cart_payment_type_cash_pay" data-property-id="1" />
<label for="cart_payment_type_cash_pay">Cash</label>
</div>
<div class="vertical-button-wrapper">
<input type="radio" value="credit" name="cart[payment_type]" id="cart_payment_type_credit_pay" data-property-id="1" />
<label for="cart_payment_type_credit_pay">Credit</label>
</div>
</div>
<div style="display: none;" id="cart_room_number_area_pay">
<div class="control-group string optional cart_room_number">
<label for="cart_room_number_pay" class="string optional control-label">Room number</label>
<div class="controls">
<input type="text" value="" size="50" name="cart[room_number]" id="cart_room_number_pay" class="string optional" />
</div>
</div>
</div>
<input type="checkbox" value="1" style="display: none;" name="receipt" id="receipt" />
<div class="sell-modal-footer">
<input type="submit" value="Complete With Receipt" name="commit" id="cart_complete_with_receipt" data_disable_with="Processing..." class="btn btn-danger" />
<input type="submit" value="Complete Sale" name="commit" data_disable_with="Processing..." class="btn btn-danger" />
</div>
</form>
</div>
I've tried as many different equivalent ways of getting at it that I can think of. Most obviously just by the label, or the ID, like:
choose 'cart_payment_type_cash_pay'
choose 'Cash'
which just gives me the error:
Unable to find radio button "cart_payment_type_cash_pay" (Capybara::ElementNotFound)
I thought it might have something to do with the modal dialog, visibility, etc. but I introduced the ID #payment_fat_buttons just for testing, and when I look for it like this:
find('#payment_fat_buttons').choose('Cash')
it finds that DIV OK, but still not the radio button. I also tried getting at it with :xpath on the whole page, and within a scope like:
within(:xpath, "//div[#id='payment_methods']") do
find(:xpath, ".//input[#id='cart_payment_type_cash_pay']").choose
end
which acts like it can also find the outer DIV, but not the radio button - I get the error:
Unable to find xpath ".//input[#id='cart_payment_type_cash_pay']" (Capybara::ElementNotFound)
Generally, it seems like I can find any arbitrary element around the radio buttons with :xpath or CSS expressions, just not the radio buttons. I can also push the submit buttons on the form without any problem. I tried dropping the data attributes as a test - no difference. Any help would be greatly appreciated. This is driving me nuts because it seems so simple, and yet I'm getting nowhere. I need to choose that for a big segment of Scenarios, so if I can't figure it out, I'll have to resort to something hokey and horrible. Many thanks in advance...
Relevant versions from Gemfile.lock:
rails (3.2.13)
cucumber (1.3.8)
gherkin (2.12.2)
cucumber-rails (1.4.0)
capybara (2.1.0)
selenium-webdriver (2.35.1)
I finally figured this one out. Capybara wasn't finding the radio button because buried deep in my styles was some CSS that hid it in order to change the appearance. Once I realized that, I figured out that I could side-step the whole issue of finding the radio button by just doing a click on the label instead:
find(:xpath, "//label[#for='the_radio_button_id']").click
I didn't realize it was possible to get at radio buttons that way - but in any case, it solves the issue of how to click a radio button that Capybara won't find due to styling or other issues. Hope that helps someone else.

ContentType appears to be a "Computed" field and not "Choice" field through API - SharePoint 2010

We are trying to use the ListFieldIterator control to display the edit form of a list item including the content type. When viewing the list item in edit mode in the UI, the content type shows up as a dropdown with the list of content types but when going through the listfielditerator, the "content type" field shows up as a computed field but not as a "choice" field.
When looking at this field through SharePoint manager, the field shows up as a Choice but not as a dropdown but in SP2007, the content type field shows up as a "Choice" field. Is there any way to resolve this issue? How does the content type appear as a dropdown if internally, it is a choice field in SP2010?
Thanks in advance for your time.
A regular Edit Form does not render the Content Type through the ListFieldIterator control, but through the ChangeContentType control. I'm surprised the ListFieldIterator is displaying the Content Type field. It should be filtered out by IsFieldExcluded.
<SharePoint:RenderingTemplate id="ListForm" runat="server">
<Template>
<span id='part1'>
<SharePoint:InformationBar runat="server"/>
<div id="listFormToolBarTop">
<wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" RightButtonSeparator="&#160;" runat="server">
<Template_RightButtons>
<SharePoint:NextPageButton runat="server"/>
<SharePoint:SaveButton runat="server"/>
<SharePoint:GoBackButton runat="server"/>
</Template_RightButtons>
</wssuc:ToolBar>
</div>
<SharePoint:FormToolBar runat="server"/>
<SharePoint:ItemValidationFailedMessage runat="server"/>
<table class="ms-formtable" style="margin-top: 8px;" border="0" cellpadding="0" cellspacing="0" width="100%">
<SharePoint:ChangeContentType runat="server"/> <!-- ChangeContentType -->
<SharePoint:FolderFormFields runat="server"/>
<SharePoint:ListFieldIterator runat="server"/> <!-- ListFieldIterator -->
<SharePoint:ApprovalStatus runat="server"/>
<SharePoint:FormComponent TemplateName="AttachmentRows" runat="server"/>
</table>
<table cellpadding="0" cellspacing="0" width="100%"><tr><td class="ms-formline"><img src="/_layouts/images/blank.gif" width='1' height='1' alt="" /></td></tr></table>
<table cellpadding="0" cellspacing="0" width="100%" style="padding-top: 7px"><tr><td width="100%">
<SharePoint:ItemHiddenVersion runat="server"/>
<SharePoint:ParentInformationField runat="server"/>
<SharePoint:InitContentType runat="server"/>
<wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbl" RightButtonSeparator="&#160;" runat="server">
<Template_Buttons>
<SharePoint:CreatedModifiedInfo runat="server"/>
</Template_Buttons>
<Template_RightButtons>
<SharePoint:SaveButton runat="server"/>
<SharePoint:GoBackButton runat="server"/>
</Template_RightButtons>
</wssuc:ToolBar>
</td></tr></table>
</span>
<SharePoint:AttachmentUpload runat="server"/>
</Template>
</SharePoint:RenderingTemplate>