How to bind to checkbox list sql datasource select with stored procedure - sqldatasource

I get this error when I call in code behind file.
Procedure or function 'GetALLSurveyor_ForTeam_Update' expects parameter '#ID', which was not supplied.
My code is
sdsSurveyor.SelectParameters.Add("#ID", TeamID)
sdsSurveyor.SelectCommand = "GetALLSurveyor_ForTeam_Update"
sdsSurveyor.InsertCommandType = SqlDataSourceCommandType.StoredProcedure
chklistsurveyor.DataSourceID = "sdsSurveyor"
chklistsurveyor.DataBind()
and in aspx file
<asp:CheckBoxList ID="chklistsurveyor" CellSpacing="10" CellPadding="10" RepeatLayout="Table"
CssClass="mycheckbox" TextAlign="Right" DataTextField="NAME" DataValueField="ID"
RepeatDirection="Horizontal" RepeatColumns="2" runat="server">
</asp:CheckBoxList>
<asp:SqlDataSource ID="sdsSurveyor" ConnectionString="<%$ ConnectionStrings:ApplicationServices%>" runat="server">
</asp:SqlDataSource>

You need to set the sdsSurveyor.SelectCommandType to SqlDataSourceCommandType.StoredProcedure, too! (not just the .InsertCommandType as you already do in your code):
sdsSurveyor.SelectParameters.Add("#ID", TeamID)
sdsSurveyor.SelectCommand = "GetALLSurveyor_ForTeam_Update"
// make sure you have this line in there somewhere
sdsSurveyor.SelectCommandType = SqlDataSourceCommandType.StoredProcedure

Related

Omniture tagging - Fire a start event on Onchange (Not Working !!!!)

I am a newbie to Omniture tagging. The company has provided specs and I am following that. I want to fire a start event when the value in the dropdown changes. I don't know what I am missing because it refuses fire the event. I am using Omnibug to test.
<select name="seltest" onChange = "var s=s_gi('ds-prod');tmsomni.linkTrackVars=
'prop6,prop64';tmsomni.linkTrackEvents = 'event54';tmsomni.prop6 = 'vehicle
request';tmsomni.prop64 = 'vehicle'; s.tl(true, 'o');">
<option>1</option>
<option>2</option>
</select>
Your setting the tracking object to s and then using tmsomni to set values in the tracking object. It should look more like this:
<select name="seltest" onchange="window.tmsomni=s_gi('ds-prod');tmsomni.linkTrackVars= 'prop6,prop64';tmsomni.linkTrackEvents = 'event54';tmsomni.prop6 = 'vehicle request';tmsomni.prop64 = 'vehicle'; tmsomni.tl(true, 'o');">
<option>1</option>
<option>2</option>
</select>
Or perhaps the inverse where you would replace all tmsomni with s.
Also set the events variable as below:
<select name="seltest" onchange="window.tmsomni=s_gi('ds-prod');tmsomni.linkTrackVars= 'prop6,prop64';tmsomni.linkTrackEvents = 'event54';tmsomni.events = 'event54';tmsomni.prop6 = 'vehicle request';tmsomni.prop64 = 'vehicle'; tmsomni.tl(true, 'o');">
<option>1</option>
<option>2</option>
</select>
It worked , I was missing the name of the link.

Create table dynamically in jQuery Mobile

I am creating table plugin in JQM in html file. It works properly
html page
<table data-role="table" data-mode="columntoggle" class="ui-responsive table" id="service">
....
</table>
But i want to create a table dynamically. when doing this. JQM default plugin isn't apply
My code is
var service_table = $('<table data-role="table" data-mode="columntoggle" class="ui-responsive table" id="service"></table>')
var service_tr_th = $("<tr><th>Name</th></tr>");
var service_tr=$('<tr></tr>');
var service_name_td=$('<td>'+retServiceName+'</td>');
$(service_name_td).appendTo(service_tr);
$(service_tr_th).appendTo("#categories");
$(service_tr).appendTo(service_table);
$(service_table).appendTo("#categories");
in Html page
<div id="categories"></div>
When creating a column toggle table, add THEAD and TBODY, and data-priority="x" to the header cells (see http://demos.jquerymobile.com/1.4.2/table-column-toggle/). Finally call the .table() method to tell jQM to enhance the table:
var service_table = $('<table data-role="table" data-mode="columntoggle" class="ui-responsive table-stroke" id="service"></table>');
var service_tr_th = $("<thead><tr><th data-priority='1'>Name</th><th>Col2</th data-priority='2'></tr></thead>");
var service_tbody = $('<tbody></tbody>');
var service_tr = $('<tr></tr>');
var service_name_td = $('<td>' + retServiceName + '</td><td></td>');
service_name_td.appendTo(service_tr);
service_tr_th.appendTo(service_table);
service_tr.appendTo(service_tbody);
service_tbody.appendTo(service_table);
service_table.appendTo($("#categories"));
service_table.table();
Here is a DEMO
NOTE: you don't need $() around variables that are already jQuery collections e.g. service_tr, service_name_td, etc.

How do I use ViewBag string in partial view javascript

I am returning this from a partial view:
<script>
document.getElementById("login").style.visibility = "hidden";
document.getElementById("displayname").innerHTML = #ViewBag.DisplayName
</script>
The second script line, however, does not work.
How to write this correctly?
Greg
#Html.Raw("document.getElementById(\"displayname\").innerHTML = " + #ViewBag.DisplayName)

Strange error in Razor view, in Orchard CMS

When I have this:
#using Orchard.Themes.Models
#using Orchard.Themes.Preview
#using Orchard.Themes.Services
#using Orchard.Themes.ViewModels
#{
Script.Require("OrchardTinyMceDeluxe");
var pluginsBaseUrl = #Url.Content("~/modules/tinymcedeluxe/scripts/plugins");
var siteThemeService = WorkContext.Resolve<ISiteThemeService>();
}
I get this error:
Parser Error Message: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.
Line 4: #using Orchard.Themes.Services
Line 5: #using Orchard.Themes.ViewModels
Line 6: #{
Line 7: Script.Require("OrchardTinyMceDeluxe");
Line 8: var pluginsBaseUrl = #Url.Content("~/modules/tinymcedeluxe/scripts/plugins");
But if I break the code up into two separate C# blocks, as shown below, it works fine. Why?
#{
Script.Require("OrchardTinyMceDeluxe");
var pluginsBaseUrl = #Url.Content("~/modules/tinymcedeluxe/scripts/plugins");
}
#{
var siteThemeService = WorkContext.Resolve<ISiteThemeService>();
}
You shouldn't use the # on Url.Content, it's already inside a code block.
What I think is happening is that razor is getting confused by the # and the semicolon at the end, thus placing the close bracket into the HTML.

asp.net mvc razor multiply two item and convert to string

When I write #(line.Quantity * line.Product.Price).ToString("c") the result is
39,00.ToString("c")
and #line.Quantity * line.Product.Price.ToString("c") result is
2 * line.Product.Price.ToString("c")
How can i multiply two values and convert it to string in a razor view?
try
#((line.Quantity * line.Product.Price).ToString("c"))
The problem is that razor do not know when the output string ends since # is used to display code in HTML. Spaces switches razor back to HTML mode.
Wrapping everything into parenthesis makes razor evaluate the entire code block.
Although the most proper way would be to introduce a new property in your model:
public class MyModel
{
public double Total { get { return Quantity * Product.Price; }}
//all other code here
}
and simply use:
#line.Total.ToString("c")
this is an old question but I have just had the same issue and here is the resolution for it.
If you need to perform a calculation on a razor view, you can do it the following way:
if you are outside of c# block (such as #foreach or #if ):
you can wrap your calculation into #{ } and they won't be rendered.
<p>Some text</p>
#{ var x = Model.Y * Model.Z; }
<p>X equals #x.ToString()</p>
if you are inside of a c# block:
you can simply put your calculations in { }.
<p>Some text</p>
#foreach (var x in Model.Y)
{
{ var z = x * 2; }
<p>Z equals #z.ToString()</p>
}

Resources