I have a SQL column with the name of "documents" that hold all the uploaded documents name like this: test1.doc;test2.pdf;test3.pdf. Some records for this column has no data or only has one or two documents. In my FormView I have 3 hyperlinks like this:
**//Hyperlink # 1**
<asp:HyperLink ID="HyperLink1" runat="server" Text='<%# If(Eval("documents") Is DBNull.Value, "No
document available", Eval("documents").ToString().Split(";")(0)) %>' NavigateUrl='<%#
String.Format("~/documents/uploads/{0}", Eval("documents").ToString().Split(";")(0)) %>' >
</asp:HyperLink><br />
**//Hyperlink # 2**
<asp:HyperLink ID="HyperLink2" runat="server" Text='<%# If(Eval("documents") Is DBNull.Value, "No
document available", Eval("documents").ToString().Split(";")(1)) %>' NavigateUrl='<%#
String.Format("~/documents/uploads/{0}", Eval("documents").ToString().Split(";")(1)) %>' >
</asp:HyperLink><br />
**//Hyperlink # 3**
<asp:HyperLink ID="HyperLink3" runat="server" Text='<%# If(Eval("documents") Is DBNull.Value, "No
document available", Eval("adocuments").ToString().Split(";")(2)) %>' NavigateUrl='<%#
String.Format("~/documents/uploads/{0}", Eval("documents").ToString().Split(";")(2)) %>'>
</asp:HyperLink>
When the document column has only 1 document, I'm getting the error message: Index was outside the bounds of the array and it points to Hyperlink # 2. But if a record has 3 documents name, it shows all 3 records as expected. I really appreciate any help or guide me to the right direction.
That is clear because creating an array with .Split you aren’t sure about array length.
So passing a parameter to get an element by this array you have to be sure that array contains the element which means you need to be sure the array length is > to index you want to get.
In this case just add a test for that as the code below shows (index is the parameter 0, 1, 2 etc….)
<%# If(Eval("documents") Is DBNull.Value OrElse Eval("documents").ToString().Split(";").Length < index, "No document available", Eval("documents").ToString().Split(";")(index)) %>
Related
I'm trying to display field values in comma separated using multi valued report parameter with below expression, but report itself is showing blank.
="all values" & JOIN(Parameters!ReportParameter2.Label)
I've dataset named 'Sessions' having fields as below -
Id, typeof(int)
MeetingId, typeof(int)
SessionType, typeof(string)
I created multi valued report parameter in RDLC as below -
General:
Name: ReportParameter2
Data type : Text
Allow multiple values: checked
Available values:
Get values from a query : radio button checked
Dataset: Sessions
Value field: Id
Label field: SessionType
Default values:
Get values from a query : radio button checked
Dataset: Sessions
Value field: Id
My code in .aspx.cs, button click event as follows -
DataTable table = new DataTable();
table.Columns.Add("Id", typeof(int));
table.Columns.Add("MeetingId", typeof(int));
table.Columns.Add("SessionType", typeof(string));
table.Rows.Add(1, 1, "case1");
table.Rows.Add(2, 1, "case2");
datasource = new ReportDataSource("Sessions", table);
ReportViewer1.LocalReport.DataSources.Add(datasource);
My code in .aspx, as follows -
<%# Register assembly="Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" AsyncRendering="true"
Style="width:100%;height:700px;"
OnReportError="ReportViewer1_ReportError"></rsweb:ReportViewer>
<asp:Button OnClick="CaseList_Click" ID="Button2" runat="server" Text="CaseList" />
</form>
From last 2 days I'm working on this issue, please help me..
I have following code which is a drop down list of flight locations:
Where to:<br />
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1"
DataTextField="Destination"
DataValueField="Destination" Width="222px">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [Destination] FROM [tblFlight]">
</asp:SqlDataSource>
I want to be able to use the selected value from the drop down list above (one of them is Corfu) as the WHERE condition of a query that will only select the flights going to Corfu.
Any suggestions?
basically:
string dest = yourDropDown.SelectedItem;
SELECT [Destination] FROM [tblFlight] WHERE [Destination] = " + dest;
I need filter a assetset by id, my asset type is a flex asset. I never do this by id before and I'm stucked with this.
This is my code:
<publication:load name="pub" field="name" value='<%= ics.GetVar("site") %>'/>
<publication:get name="pub" field="id" output="siteId"/>
<%-- Content:getasset data is a custom tag to obtain attributes form a concrete asset --%>
<content:getassetdata prefix="lov" id='<%= ics.GetVar("assetid") %>' type="LOV" attributes="LOVUser"/>
<listobject:create name="powerObject" columns="power"/>
<c:forEach items="${lov.LOVUser}" var="usu">
<listobject:addrow name="powerObject"><listobject:argument name="power" value="${usu.id}"/></listobject:addrow>
</c:forEach>
<listobject:tolist name="powerObject" listvarname="powerList"/>
<%-- A this time, I have a powerList with all the IDs that I need to get --%>
<searchstate:create name="ssLovElements"/>
<searchstate:addstandardconstraint name="ssLovElements" attribute="id" list="powerList" />
<assetset:setsearchedassets name="asElementLovs" constraint="ssLovElements" assettypes="elementLOV" site='<%= ics.GetVar("siteId") %>' fixedlist="false"/>
<%-- Correct number --%>
<br/> N.Filas powerList: <ics:listget listname="powerList" fieldname="#numRows"/>
<%-- Incorrect number (Because constraint haven't effect --%>
N.Filas aslist: <ics:listget listname="aslist" fieldname="#numRows"/>
First list have 60 elements, second list have 600. I need use this constraint to extrac only wanted elements and get their attributes with multiplevalues, but I dont get working this. Any help? Thanks
I think you should use the Asset API instead of jstl tag. See the doc :
Session ses = SessionFactory.getSession();
AssetDataManager mgr = (AssetDataManager) ses.getManager(AssetDataManager.class.getName());
Condition c = ConditionFactory.createCondition( "id", OpTypeEnum.GREATER_THAN, long);
Query query = new SimpleQuery( "elementLOV", null, c, Arrays.asList( "name", ) );
query.getProperties().setIsBasicSearch( true );
I have a Radgrid and I bind it with SqlAdapter. My problem is that I want to change just one column's value. Is that possible?
My column name is IsShadow and it binds true or false. I cannot change it. If value is false or true, I change column text appearence, not database update.
Code I've tried
foreach (Telerik.Web.UI.GridDataItem dataItem in gridShadow.MasterTableView.Items)
{
bool flag = Convert.ToBoolean(dataItem.GetDataKeyValue("IsShadow"));
GridEditableItem editedItem = dataItem as GridEditableItem;
if (!flag)
{
TableCell tableCell = editedItem["IsShadow"] = ???
}
}
Thank you.
Please try with the below code snippet and let me know if any concern.
// Normal Mode
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
item["IsShadow"].Text = "Your new text";
}
// Edit Mode
if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
{
GridEditableItem editItem = (GridEditableItem)e.Item;
(editItem["IsShadow"].Controls[0] as TextBox).Text = "Your new text";
}
You probably need a GridTemplateColumn
In the ItemTemplate you will check the value of IsShadow and display some text, but in EditItemTemplate you would probably need to just have a checkbox for true/false.
<telerik:GridTemplateColumn HeaderText="Is Shadow" UniqueName="TemplateColumn">
<EditItemTemplate>
<asp:CheckBox id="editChkBox" runat="server"
Checked='<%# Bind("IsShadow") %>'>
</asp:CheckBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Lable id="lblIsShadow" runat="server"
Text='<%# Convert.ToBoolean(Eval("IsShadow")) == true ? "it is shadow" : "Not shadow" %>'>
</asp:CheckBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
I'm developing a website for Tenants to find properties. When they sign up, they can choose the property types that they are interested, for example: Apartment or House.
When a Tenant logs into their account, they can then do a search for properties. The search form is prepopulated with the values that they originally entered on sign up, for example: City, Postcode and so on.
The form also needs to display some checkboxes with the relevant boxes ticked for the Property Types that they selected on sign up. I'm having some problems getting this to work and wondered if there is anyone who could correct the code for me?
I believe I need to use an 'IN' statement so that the relevant checkboxes would be ticked, if the IDs for those properties are found in the CustomerReqPropertyType column. The CustomerReqPropertyType column is varchar(50) and as an example, if a user has selected Apartment and House, it is store in the row as 2, 4 (as there is a separate table with the Property Types.
This is the code I have on the page;
<%
While (NOT rspropertytype.EOF)
%>
<li>
<input type="checkbox" name="txtPropertyType" id="txtPropertyType" value="<%=(rspropertytype.Fields.Item("PropertyTypeID").Value)%>"<% If Not rstenantrequirements.EOF Or Not rstenantrequirements.BOF Then %><%If (Not isNull((rstenantrequirements.Fields.Item("CustomerReqPropertyType").Value))) Then If (CStr(rspropertytype.Fields.Item("PropertyTypeID").Value) = CStr((rstenantrequirements.Fields.Item("CustomerReqPropertyType").Value))) Then Response.Write("")%><% End If ' end Not rstenantrequirements.EOF Or NOT rstenantrequirements.BOF %> />
<label for="txtPropertyType"><%=(rspropertytype.Fields.Item("PropertyTypeTitle").Value)%></label>
</li>
<%
rspropertytype.MoveNext()
Wend
If (rspropertytype.CursorType > 0) Then
rspropertytype.MoveFirst
Else
rspropertytype.Requery
End If
%>
I would be very grateful for any help.
In order for a checkbox to be checked the checked property must equal "checked".
e.g.
<input type="checkbox" name="something" value="somethingElse" checked="checked" />
I suspect that in your code the rspropertytype and rstenantrequirements recordsets could be consolidated into one recordset generated from one SQL statement.
e.g.
SELECT pt.*
, CASE
WHEN ISNULL(tr.CustomerReqPropertyType,0) = 0 THEN 0
ELSE 1 END AS [checked]
FROM propertytype AS [pt]
LEFT JOIN tenantrequirements AS [tr]
ON pt.PropertyTypeID = tr.CustomerReqPropertyType
WHERE ...
Then your ASP code could be simplified as well.
e.g.
<%
While (NOT rs.EOF)
Dim pID : pID = rs("PropertyTypeID")
Dim pTitle : pTitle = rs("PropertyTypeTitle")
Dim checked : checked = "" : If (rs("checked") = 1) Then checked = "checked"
%>
<li>
<input type="checkbox" name="txtPropertyType" id="txtPropertyType<%=pID%>" value="<%=pID%>" checked="<%=checked%>" />
<label for="txtPropertyType<%=pID%>"><%=pTitle%></label>
</li>
<%
rs.MoveNext()
Wend
%>
This is really hard to follow. First I'd break up that line to where your while is you can just set a variable and print that to page. I assume you're trying to set the checkbox checked. What I would do is make sure the value returned isn't null assuming this is a query that just returns the property type and you left joined it with the table that has the descriptions in it when they are set for the property in question. I don't see you ever print checked to the checkbox so it's never going to be checked anyway.