I have an ASP.Net GridView and I want to include an Image and a Text in the same field, something like this:
<a id="lnkForJQueryCall"><img src="whatever.png"> Some Other Number</a>
I have found the asp:ImageField does not have a Property for adding a text at right or left of the image, and there are no much options, is there any way to achieve it?
[EDIT] I was thinking of a css class workaround but have not figured out how to do it !!
You can use a TemplateField to display custom content in a data-bound control such as a GridView.
<asp:TemplateField>
<ItemTemplate>
<a id="lnkForJQueryCall"><img src="whatever.png"> Some Other Number</a>
</ItemTemplate>
</asp:TemplateField>
Related
When hovered over the text 'Bedroom', the blue dotted box appears over it, but clicking on it, does not place the cursor, as if it is read-only.
However, I am able to edit the rendered images. And also the text 'Water View Loft' coming from another repeater, without issues.
ascx:
<asp:Repeater ID="rpPhotos" runat="server" ItemType="Sitecore.Data.Items.Item">
<ItemTemplate>
<div class="item">
<p>
<sc:Text runat="server" Field="Title" Item="<%#Container.DataItem %>"/>
</p>
<sc:Image runat="server" Field="Image" Item="<%#Container.DataItem %>" />
</div>
</ItemTemplate>
</asp:Repeater>
The fields Title & Image are from a template called Base Content. I have used this template to render other repeater in the same user control & there I can edit the text & images.
Why is this happening?
Try to remove the <p> tag, and see if the field gets editable. The Page Editor gets broken on nested <p> tags, and perhaps it happens also in your case.
Try to set the DisableWebEditing="false".
Whenever I set caption property to blank in an ASP.net gridview it does not show up in html. how can I add empty caption in gridview so that in html it shows up as <caption/> rather than not showing up at all.
<asp:GridView ID="gvClients" runat="server" Caption="">
Can you please say in more details, why you require tag if there is no any text for the grid or table header?
If you require it by specific reason then you can add the space as below in your code.
<asp:GridView ID="gvClients" runat="server" Caption=" ">
I use Microsoft.SharePoint.WebControls.SPGridView control to write out data.
Filtering is allowed for grid.
Columns contain templated column, it define ItemTemplate and HeaderTemplate:
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:LinkButton ID="linkTitleHeader" runat="server" Text="TitleHeader1"
CommandName="Sort" CommandArgument="Title"></asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
some text
</ItemTemplate>
</asp:TemplateField>
</Columns>
It works fine, shows header as link, its performs sorting by click, but filter menu
show on separate row:
i expect that it shows as:
I already try with no result:
Leave Text property empty and define other properties
Set Microsoft.Sharepoint.WebControls.Menu Text programmaticaly after
databind
Set link text by javascript
Have any ideas how to join Menu with LinkButton ? Thanks.
You must also specify the properties of SPGridView : FilterDataFields, FilteredDataSourcePropertyName, FilteredDataSourcePropertyFormat. Maybe this article will help you link
I'm using a TemplateField for a column because I need the HeaderTemplate. However, the ItemTemplate renders the content of a cell as an <asp:Label> and the output looks like this:
<td><span>data</span></td>
Is there any way to make the ItemTemplate just render the content of the cell so that the output will look like this:
<td>data</td>
Thanks for any suggestions.
The built in templates that are autogenerated will always use a Label for simplicity because they assume you might want to do formatting. If you want to just get basic HTML out switch it to use a Literal instead of a Label. A Literal acts almost the same as a Label with no formatting so there is no span tags. Change your TemplateField to the following:
<asp:TemplateField>
<ItemTemplate>
<asp:Literal ID="ltTestItem" runat="server" Text="Test" />
</ItemTemplate>
</asp:TemplateField>
It will produce:
<td>Test</td>
You can do the binding however you want by replacing the Text value with Eval("yourField") or by implementing the OnDataBinding for the control and manipulate it however you like.
Hi i want to display an image on a Linkbutton to make it looks attractive in asp.net
any one have idea how to do it...
<asp:LinkButton runat="server" ...>
<img src="yourimageurl" />
</asp:LinkButton>
Why not use ImageButton?