I want to show Images in my datalist. Image URLs are stored in my database. For some reason urls can't be retrived from my database.
Anyone knows what Am I missing? Here is my code.
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatColumns="3" Width="100%">
<ItemTemplate>
<asp:Image runat="server" ImageUrl="http://mywebsite.com/folder/{0}" Width="100%" />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [url] FROM [MyDatabase]"></asp:SqlDataSource>
There is problem in binding image to image control. Try this.
<asp:Image runat="server" ImageUrl='<%# "http://mywebsite.com/folder/" + Eval("url") %>' Width="100%" />
Or
<asp:Image runat="server" ImageUrl='<%# "~/folder/" + Eval("url") %>' Width="100%" />
Related
I want to convert the gridview function to rows. I have a header saying "Content Manager" and I have their username displayed below it. I want the username to be able to be displayed to the right of the "content manager" text. Thank you!
<asp:SqlDataSource ID="SqlDataSource19" runat="server" ConnectionString="<%$ ConnectionStrings:IntranetDB %>" SelectCommand="SELECT [id], [username], [grouping], [isContentManager], [CMRegion] FROM [Permissions] WHERE (([grouping] = 'marketing') AND ([isContentManager] = 'yes'))">
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource19">
<Columns>
<asp:BoundField DataField="username" HeaderText="Content Manager" SortExpression="username" />
</Columns>
</asp:GridView>
<ej:Grid ID="Grid1" runat='server'></ej:Grid>
You can try DataList and set its RepeatDirection to Horizontal.
<form id="form1" runat="server">
<div style="float: left">
<asp:Label runat="server">Content Manager: </asp:Label>
</div>
<div style="float: left">
<asp:DataList ID="DataList1"
RepeatDirection="Horizontal"
RepeatLayout="Table"
RepeatColumns="0" runat="server">
<ItemTemplate>
<%# Eval("UserName") %>
</ItemTemplate>
</asp:DataList>
</div>
</form>
Is it possible to access the Text of ProductName inside this Hyperlink (DATALIST) ?
Thank you!!
<asp:DataList ID="DataList1" runat="server" CellPadding="0" RepeatColumns="4" RepeatDirection="Horizontal" ShowFooter="False" ShowHeader="False" OnSelectedIndexChanged="DataList1_SelectedIndexChanged">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" Text='<%# Eval("productName") %>' runat="server" Font-Size="Large"></asp:HyperLink>
</ItemTemplate>
</asp:DataList>
I am getting this error
"Both DataSource and DataSourceID are defined on 'DataListCity'. Remove one definition."
This is the code from my Masterpage that is causing the error
<asp:DataList ID="DataListCity" runat="server" Width="100%"
onitemcommand="DataListCity_ItemCommand" CellPadding="4"
ForeColor="#333333" DataSourceID="SqlDataSource1">
<ItemTemplate>
CityId:
<asp:Label ID="CityIdLabel" runat="server" Text='<%# Eval("CityId") %/>
<br />
CityName:
<asp:Label ID="CityNameLabel" runat="server" Text='<%# Eval("CityName")%>' />
<br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource
ConnectionString="<%$ ConnectionStrings:HotelConnString %>"
ID="SqlDataSource1" runat="server"
SelectCommand="SELECT [CityId], [CityName], [Description] FROM [Categories]">
</asp:SqlDataSource>
Remove your binding code from cs if you have written in code behind because you can bind only by code behind or from design not both at same time
Remove these lines from code behind
DataListCity.DataSource=somesource;
DataListCity.DataBind();
I am trying to create a dropdown with check-box using textbox and popup control extender but i am getting this error whenever i run it:
Error: 'Sys.Extended.UI' is null or not an object'.
I am trying to make as simple as possible but not sure what am i missing here. Here is the code:
<asp:TextBox ID="ddl_TextLog" runat="server" AutoPostBack="true" BackColor="#FFFFCC" Style="background-color: #FFCC66" Width="250px"></asp:TextBox>
<asp:PopupControlExtender ID="TextBox1_PopupControlExtenderLog" runat="server" Enabled="True" ExtenderControlID="" TargetControlID="ddl_TextLog" PopupControlID="pnl_Log" OffsetY="22"></asp:PopupControlExtender>
<asp:Panel ID="pnl_Log" runat="server" Height="180px" Width="250px" BorderStyle="Solid" BorderWidth="2px" Direction="LeftToRight" ScrollBars="Auto" BackColor="#FFFFCC" Style="display: none">
<asp:CheckBoxList ID="CheckBoxList_Log" runat="server" DataSourceID="SqlDataSource_Log" DataTextField="MDE" DataValueField="MDE" AutoPostBack="True" OnSelectedIndexChanged="CheckBoxList_Log_SelectedIndexChanged"></asp:CheckBoxList>
<asp:SqlDataSource ID="SqlDataSource_Log" runat="server" ConnectionString="<%$ ConnectionStrings:DCR-DWH-MS-01-DA2 %>" SelectCommand=" SELECT DISTINCT MDE FROM myTable ORDER BY MDE ASC"></asp:SqlDataSource>
</asp:Panel>
i had to use this and fixed my issue:
<ajaxToolkit:ToolkitScriptManager runat="server" ID="ToolkitScriptManager1" />
I have this code
<asp:GridView ID="gvCentersList" runat="server" AutoGenerateColumns="False"
DataKeyNames="CenterID" DataSourceID="SqlDataSource1" CssClass="gv-classic">
<Columns>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:CheckBox ID="GridCheckBox" runat="server" onclick="javascript:func1150(this,<%#response.write(CenterID)%>);" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CenterID" HeaderText="CenterID" SortExpression="CenterID" />
<asp:BoundField DataField="CenterName" HeaderText="CenterName" SortExpression="CenterName" />
</Columns></asp:GridView><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" SelectCommand="SELECT ROW_NUMBER() OVER (ORDER BY CityName ASC) AS ROWID, * FROM [CentersList]"></asp:SqlDataSource>
my question in this line
onclick="javascript:func1150(this,<%=CenterID%>);"
how can I pass the CenterID to the func1150 ?
You may try like this:
<asp:CheckBox
ID="GridCheckBox"
runat="server"
onclick='<%# string.Format("javascript:func1150(this, \"{0}\")", Eval("CenterID")) %>'
/>
But do you really need a server side checkbox here? If not this could be more readable:
<input
type="checkbox"
onclick="javascript:func1150(this, '<%# Eval("CenterID") %>');"
/>
From my understanding of your question,
onclick=javascript:func1150(this,'<%# Eval("CenterID")%>');
A better way would be adding the onclick attribute from code behind.