I'm using this code:
Dim VehiclesTable1 = dsVehicleList.Tables(0)
Dim VT1 = (From d In VehiclesTable1.AsEnumerable _
Select VehicleTypeName = d.Item("VehicleTypeName") _
, VTypeID = d.Item("VTypeID") _
, ImageURL = d.Item("ImageURL") _
, DailyRate = d.Item("DailyRate") _
, RateID = d.Item("RateID")).Distinct
its linq to dataset
and I Take Data on THis Rotator:
<telerik:RadRotator ID="RadRotatorVehicleType" runat="server" Width="620px" Height="145"
ItemWidth="155" ItemHeight="145" ScrollDirection="Left" FrameDuration="1" RotatorType="Buttons">
<ItemTemplate>
<div style="text-align: center; cursor: pointer; width: 150px">
<asp:Image ID="ImageVehicleType" runat="server" Width="150" ImageUrl='<%# Container.DataItem("ImageURL") %>' />
<asp:Label ID="lblVehicleType" runat="server" Text='<%# Container.DataItem("VehicleTypeName") %>'
Font-Bold="true"></asp:Label>
<br />
<asp:Label ID="lblDailyRate" runat="server" Text='<%# Container.DataItem("DailyRate") %>'
Visible="False"></asp:Label>
<input id="HiddenVehicleTypeID" type="hidden" value='<%# Container.DataItem("VTypeID") %>'
name="HiddenVehicleTypeID" runat="server" />
<input id="HiddenRateID" type="hidden" value='<%# Container.DataItem("RateID") %>'
name="HiddenRateID" runat="server" />
</div>
</ItemTemplate>
<ControlButtons LeftButtonID="img_left" RightButtonID="img_right" />
</telerik:RadRotator>
and I got this Exception:
No default member found for type 'VB$AnonymousType_0(Of Object,Object,Object,Object,Object)'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MissingMemberException: No default member found for type 'VB$AnonymousType_0(Of Object,Object,Object,Object,Object)'.
I don't know whats up ?
Any help please.
Thanks for who tried to solve this
but I got solution:
using '<%# DataBinder.Eval(Container.DataItem,"ImageURL") %>'
instead of '<%# Container.DataItem("RateID") %>'
Thanks,
Thanks for who tried to solve this but I got solution:
using '<%# DataBinder.Eval(Container.DataItem,"ImageURL") %>'
instead of '<%# Container.DataItem("RateID") %>'
Thanks,
Related
I cannot figure out why I am getting this error.
Original VB Code:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:db %>" SelectCommand="GetMasterBusinessCategories" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>
<asp:ListView ID="lViewMasterCategories" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<div class="col-md-6">
NAME here
<div class="row">
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:db %>" SelectCommand="GetBusinessSubCategoriesByParentID" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter Name="ParentID" ControlID="lViewMasterCategories" PropertyName="ID"/>
</SelectParameters>
</asp:SqlDataSource>
<asp:ListView ID="lViewSubCategories" runat="server" DataSourceID="SqlDataSource2">
<ItemTemplate>
<div class="col-md-6"></div>
sub-category here
</ItemTemplate>
</asp:ListView>
</div>
</div>
</ItemTemplate>
</asp:ListView>
Stored Procedure(s):
Select ID,CategoryName from BusinessDirectoryCategories with(nolock)
where IsParent = 1 order By CategoryName
and
Select ID,CategoryName from BusinessDirectoryCategories with(nolock)
where ParentID = #ParentID order By CategoryName
(both stored procedures are good and returning correct values)
Error:
enter image description here
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...
I got 2 sql tables, Categories and Posts. I select top 5 record for each category. But when I use it on accordion menu, it shows category names for each post(repeating).
Here is my code:
<asp:Accordion ID="accMenu" runat="server" DataSourceID="ods_menu" RequireOpenedPane="false">
<HeaderTemplate>
<h3><%# Eval("kategori_adi") %></h3>
</HeaderTemplate>
<ContentTemplate>
<div>
<ul>
<li><asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Eval("post_etiket") %>'>'></asp:HyperLink></li>
</ul>
</div>
</ContentTemplate>
</asp:Accordion>
<asp:ObjectDataSource ID="ods_menu" runat="server" SelectMethod="MenuGetir" TypeName="yonet"></asp:ObjectDataSource>
And my SQL command is like this (I want to select top 5 post for each category):
select top 25 p.post_id,p.post_etiket,k.kategori_id,k.kategori_adi
from post p, kategori k
where k.kategori_id= p.post_kategori_id order by post_date
How can i solve this problem?
Maybe help someone
<HeaderTemplate>
<h3><%# Eval("kategori_adi") %></h3>
</HeaderTemplate>
<ContentTemplate>
<div>
<ul >
<asp:Repeater ID="rp_altmenu" runat="server" DataSourceID="ods_alt_menu">
<ItemTemplate>
<li><asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Eval("post_etiket") %>'></asp:HyperLink></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
</ContentTemplate>
</asp:Accordion>
<asp:ObjectDataSource ID="ods_kategori" runat="server" SelectMethod="KategoriGetir" TypeName="yonet">
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ods_alt_menu" runat="server" SelectMethod="AltMenuGetir" TypeName="yonet"></asp:ObjectDataSource>
</div>
SQL sp codes of AltMenuGetir
#kategori_id int
AS
select top 5 post_id,post_etiket
from post
where post_kategori_id= #kategori_id
order by post_tarihi
SQL codes of KategoriGetir
select * from kategori
and codebehind:
protected void accMenu_ItemDataBound(object sender, AjaxControlToolkit.AccordionItemEventArgs e)
{
yonet.kategori_idy=Convert.ToInt32(DataBinder.Eval(e.AccordionItem.DataItem, "kategori_id").ToString());
}
my code gota datalist with radio button and iv made it single selectable onitemdatabound....now im trying to evaluate a hiddenfield on basis of selected radio button
my code goes like this
aspx code
<asp:DataList ID="DataList1" runat="server" RepeatColumns = "4" CssClass="datalist1"
RepeatLayout = "Table" OnItemDataBound="SOMENAMEItemBound"
CellSpacing="20" onselectedindexchanged="DataList1_SelectedIndexChanged">
<ItemTemplate>
<br />
<table cellpadding = "5px" cellspacing = "0" class="dlTable">
<tr>
<td align="center">
<a href="<%#Eval("FilePath")%>" target="_blank"><asp:Image ID="Image1" runat="server" CssClass="imu" ImageUrl = '<%# Eval("FilePath")%>'
Width = "100px" Height = "100px" style ="cursor:pointer" />
</td>
</tr>
<tr >
<td align="center">
<asp:RadioButton ID="rdb" runat="server" OnCheckedChanged="rdb_click" AutoPostBack="True" />
<asp:HiddenField ID="HiddenField1" runat="server" Value = '<%#Eval("ID")%>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
code behind
protected void SOMENAMEItemBound(object sender, DataListItemEventArgs e)
{
RadioButton rdb;
rdb = (RadioButton)e.Item.FindControl("rdb");
if (rdb != null)
rdb.Attributes.Add("onclick", "CheckOnes(this);");
}
protected void rdb_click(object sender, EventArgs e)
{
for (int i = 0; i < DataList1.Items.Count; i++)
{
RadioButton rdb;
rdb = (RadioButton)DataList1.Items[i].FindControl("rdb");
if (rdb != null)
{
if (rdb.Checked)
{
HiddenField hf = (HiddenField)DataList1.Items[i].FindControl("HiddenField1");
Response.Write(hf.Value);
}
}
}
}
the javascript im using...
function CheckOnes(spanChk){
var oItem = spanChk.children;
var theBox= (spanChk.type=="radio") ?
spanChk : spanChk.children.item[0];
xState=theBox.unchecked;
elm=theBox.form.elements;
for(i=0;i<elm.length;i++)
if(elm[i].type=="radio" &&
elm[i].id!=theBox.id)
{
elm[i].checked=xState;
}
}
iam getting an error like this
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near 'pload Demonstration|'.
is there any other way to do this or can nyone plz help to get rid of this problem
The problem is probably your Response.Write() call. Take a look at this blog post. It outlines the reasons why this particular exception shows up, and how to prevent it. Also take a look at this StackOverflow thread.
Okey lets just remove response write...now i have following in my codebehind...rest is same
label5.text=hf.value.ToString();
now i am able to evaluate Label when i use update panel nd nested updatepanel like this
<asp:UpdatePanel ID="UpdatePanel9" runat="server" >
<ContentTemplate>
<asp:DataList ID="DataList1" runat="server" RepeatColumns = "4"
CssClass="datalist1" OnItemDataBound="SOMENAMEItemBound"
CellSpacing="10" onselectedindexchanged="DataList1_SelectedIndexChanged"
HorizontalAlign="Center" Width="500px">
<ItemTemplate>
<br />
<table cellpadding = "5px" cellspacing = "0" class="dlTable">
<tr>
<td align="center">
<a href="<%#Eval("FilePath")%>" target="_blank"><asp:Image ID="Image1" runat="server" CssClass="imu" ImageUrl = '<%# Eval("FilePath")%>'
Width = "100px" Height = "100px" style ="cursor:pointer" />
</td>
</tr>
<tr >
<td align="center">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="rdb" />
</Triggers>
<ContentTemplate>
<asp:RadioButton ID="rdb" runat="server" OnCheckedChanged="rdb_click" AutoPostBack="true" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:HiddenField ID="HiddenField1" runat="server" Value = '<%#Eval("ID")%>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
</asp:UpdatePanel>
is there a way to to get this done without full page postback....asyncpostback trigger doesnt seem to work
I have a linkbutton that is nested in a datagrid that is nested in a datalist (yes, very strange, but unfortunately it's part of the site which I cannot change). Essentially I want the linkbutton to fire an event handler that calls Response.Redirect(e.CommandArgument)). In other words, I already have the URL that I want to redirect to, but I can't figure out how to get the event to trigger when I click on the linkbutton.
I have tried using the linkbutton OnClick events and the ItemCommand events for the datagrid but I dont think I am registering them correctly.
Here is the HTML for the controls.
<asp:DataList ID="dlstC" BorderWidth="0px" BorderStyle="None" CellPadding="2" CellSpacing="0"
runat="server">
<ItemTemplate>
<table cellpadding="0" cellspacing="0">
<tr style="padding-bottom: 4px">
<td style="height: 20px">
<asp:Label runat="server" ID="lblCertNum" Text='<%# "20" + (CStr(Container.DataItem("QuoteID").ToString) + "-" + CStr(Container.DataItem("QuoteRef").ToString)) %>'
Font-Bold="True" Font-Size="8pt"></asp:Label></td>
</tr>
<tr>
<td>
<asp:DataGrid ID="dgd_Certs" runat="server" ShowHeader="False" AutoGenerateColumns="False"
DataSource='<%# GetCert(CInt(Container.DataItem("QuoteRef"))) %>' BorderStyle="None"
BorderWidth="0" BorderColor="#ffffff" CellPadding="4" CellSpacing="0" OnItemCommand="DataGrid_EditItem">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="hlnCert" runat="server" Text='<%# Container.DataItem("CertName").ToString %>' CommandName="RedirectToCert"
CommandArgument='<%# BuildURLToCert(CInt(Container.DataItem("QuoteRef"))) %>' ToolTip="Click to view/edit certificate" ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Label ID="lblDate" runat="server" Text='<%# "Created - " + CStr(Container.DataItem("DateCreated").ToString)%>'></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</td>
</tr>
</table>
</ItemTemplate>
And in the code behind I have
Public Sub DataGrid_EditItem(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
If e.CommandName = "RedirectToCert" Then
Response.Redirect(e.CommandArgument.ToString)
End If
End Sub
This is my latest attempt where I am trying to get the datagrids ItemCommand to fire when the client clicks on the link, but it's not working at the moment.
Failing this, is there an easier way to redirect the client to the correct page when they click on the linkbutton? I tried using the OnPostBackURL but the issue is that there are objects that need to be carried over that dont seem to be when I do this or when I just use a hyperlink with navigateurl set.
Thanks in advance for any help, this has had me stumped for 2 days straight.
I never managed to get the event handler to fire off of the linkbutton, but I did come up with a work around for the original problem, having variables passed from one page to another. I have used a hyperlink instead of a linkbutton, and used the query strings to pass reference numbers for the objects that I need to access on the new page.