Hopefully a quick answer.

How can i edit an item in a ListView control which is nested inside a Repeater control? I've posted me code example below.

Say i have the following html:

<asp:Repeater runat="server" ID="Repeater1" 
    onitemdatabound="Repeater1_ItemDataBound">
    <ItemTemplate>
        <h1><%# Eval("Name") %></h1>
        <asp:ListView runat="server" ID="ListView1" OnItemEditing="ListView1_OnItemEditing">
            <ItemTemplate>
                <p><%# Eval("Name") %></p>
                <asp:Button Text="Edit" runat="server" CommandName="edit" CommandArgument="edit" />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="townName" runat="server" Text='<%# Eval("Name") %>'></asp:TextBox>
                <asp:Button Text="update" runat="server" />
            </EditItemTemplate>
        </asp:ListView>
    </ItemTemplate>
</asp:Repeater>

The code behind i have is:

public List<country> countries = new List<country>();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<town> tmp = new List<town>();
            tmp.Add(new town { name = "swindon" });
            tmp.Add(new town { name = "Londin" });


            countries.Add(new country() { name = "england", towns = tmp });

            tmp = new List<town>();
            tmp.Add(new town { name = "Paris" });
            tmp.Add(new town { name = "Niece" });

            countries.Add(new country() { name = "france", towns = tmp });

            tmp = new List<town>();
            tmp.Add(new town { name = "Florida" });
            tmp.Add(new town { name = "Ohio" });

            countries.Add(new country() { name = "usa", towns = tmp });


        }
        BindRepeater();
    }

    private void BindRepeater()
    {
        Repeater1.DataSource = countries.ToList();
        Repeater1.DataBind();
    }

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        ListView lv = (ListView)e.Item.FindControl("ListView1");
        lv.DataSource = ((country)e.Item.DataItem).towns.ToList();
        lv.DataBind();
    }

    protected void ListView1_OnItemEditing(object sender, ListViewEditEventArgs e)
    {
        ListView lv = (ListView)sender;
        lv.EditIndex = e.NewEditIndex;
        lv.DataBind();
    }
}

How can i actually get the ListView (which is a child of the repeater) in to edit mode so i can edit their items? The code i have at the moment simply blanks out all of the bound data on second click but does turn the ListView into edit mode (but doesn't contain any values which i set via the eval).

Hope this makes sense and hope someone can help, driving me crackers.

Thanks.

The private font that I am trying to use in my pdf is not displaying as it should. I have looked at the PDF sharp sample on their wiki, as well as examples online, but cannot get it to display with the custom font. Can anyone see anything wrong with the code below?

    PrivateFontCollection pfc = new PrivateFontCollection();

    pfc.AddFontFile(Server.MapPath(@"~\Content\Fonts\Exo-Regular.ttf"));
    XPdfFontOptions opt = new XPdfFontOptions(PdfFontEmbedding.Default);

    //I have tried both of these options:
    XFont pdfFont = new XFont(pfc.Families[0], 12, XFontStyle.Regular, opt);
    XFont exoFont = new XFont("Exo", 12);

    gfx.DrawString("Did you receive the product as ordered?", exoFont, XBrushes.Black, 50, 45, XStringFormats.Default);
    gfx.DrawString("Did you receive the product as ordered?", pdfFont, XBrushes.Black, 50, 60, XStringFormats.Default);

I am currently working on a ASP.NET project which involves assigning various permissions based on user's roles. As we know, ASP.NET itself provides a mean to manage user roles. The table, aspnet_Roles, is used to stored user defined roles, e.g. administrator, manager, etc.

In my case, there are 15 various roles already added into this table. So I am just wondering if I should stick with using aspnet_Roles table and continue adding more roles there, or perhaps should create my own Roles table and manage them separately? I am not sure if there would be any potential issues if I customize aspnet_Roles table, e.g adding new columns, increase column length, etc.

aspnet_Roles table can probably do the job, but just seems to be a bit basic and not very scalable in my opinion. The upside of it is that those Role Provider APIs are already there and I don't need to reinvent the wheel.

So what'd be the best choice here? Any suggestions?

Thanks

I am using this code to post value of selected item from the view to the controller

@using (Html.BeginForm())
{
        @Html.DropDownListFor(model => model.MyVar, (SelectList)ViewData["List"])
        <button name="Button" value="Valider">Valider</button>

}

Is there a way to send the value when the selection change in the select list (without the need to click on the button) ?

I am trying to set up TeamCity with a single project to start with.

Everything seems to work well except for when I add an “Inspections (.NET)” build step. I am getting a Module 'C' should be referenced error every time there is an @ in a .cshtml file.

How can I configure TeamCity to work correctly with .cshtml?

I'm trying to build a query to get the numbers of rows that have the same data on a column (my column is ESTADO).

 var db = Database.Open("MyDB");
 var selectedData = db.Query("SELECT COUNT (*) FROM graficos WHERE ESTADO='FECHADO'");

 var data = db.QueryValue(selectedData);

But when i try to run it gives the following error:

Compiler Error Message: CS1502: The best overloaded method match for 'WebMatrix.Data.Database.QueryValue(string, params object[])' has some invalid arguments

Line 51:      var data = db.QueryValue(selectedData);

I am using VS2012 ultimate and already clicked "show line numbers" option from text editor. VS2012 shows line numbers in models and controllers.

I know there is a way you can show line numbers with notepad++ or browser's source code. But copy, paste and search line number process is giving waste of time and also you can't do commands like "go to definition", "peek definition" vs.

Due to these reasons, I want to show line numbers in .cshtml file

I have an umbraco 7.1 website and I use its own membership system.I can easily log in,see my status,even change password BUT there is no logout command and I don't know what method I should use for umbraco 7 to logout current user.I know i can clear the cookie and member identity but it always gives a runtime error. Help me! :D

I am trying to create a number of text box dynamically in my Razor view. How can I ensure a different id is assigned to each of the text box dynamically? My objective is to access the numeric value entered in the dynamic textbox (QuestionCount) and calculate the sum of values entered.

Below is the part of code used in my view.

                            @foreach (var QP_Count in ViewBag.NonUniformTempCount)
                            {
                                var str = @ViewBag.NonUniformTempNames[tempindex];
                                <b>@str</b>
                                for (int QCount = 1; QCount <= QP_Count; QCount++)
                                {
                               **<br /> <b>@QCount               </b>  <b>@Html.TextBox("QuestionCount")</b>**                           

                                }
                                tempindex++;
                            }

I have ASP.NET MVC app which works good on my local server. When I'm deploying it into Windows Server 2008 Standard in IIS (v7.0) the app is running property (I can see panel to log in), but when I want to log in, I have such error. I have also page Contact and when I want to run it I have the same error.
I add Model.edmx using ADO.NET Entity Data Model.

The code is simple:

In controller:

private ImportEntities Entity = new ImportEntities();
public ActionResult Contact()
    {
        var dane = Entity.Contact.FirstOrDefault();
        return View("Contact",dane);
    }

Connection string in Web.config:

<add name="ImportEntities" connectionString="metadata=res://*/Models.Model.csdl|res://*/Models.Model.ssdl|res://*/Models.Model.msl;
 provider=System.Data.SqlClient;
 provider connection string=&quot;data source=AAA\aaa;
      initial catalog=Database_name;
      integrated security=True;
      MultipleActiveResultSets=True;
      App=EntityFramework&quot;"
 providerName="System.Data.EntityClient" />

The error:

Server Error in '/MyApp' Application.
Line 1: Incorrect syntax near '('. 
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.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '('.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 


Stack Trace: 

[SqlException (0x80131904): Line 1: Incorrect syntax near '('.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
...

What I don't understand: where is that moment when my app use some string connection with '('? I can't install any additional programs to debug it on server and check what is wrong.

Do you have any ideas what and where could be wrong?

I Have the Following XML Packet which comes from Google.

<?xml version="1.0" encoding="UTF-8" ?> 
- <DistanceMatrixResponse>
  <status>OK</status> 
  <origin_address>Poplar Drive, Kingsbridge, Devon TQ7 1SF, UK</origin_address> 
  <destination_address>1 Saint Michaels Road, Kingsteignton, Newton Abbot, Devon TQ12 3AQ, UK</destination_address> 
- <row>
- <element>
  <status>OK</status> 
- <duration>
  <value>2710</value> 
  <text>45 mins</text> 
  </duration>
- <distance>
  <value>37958</value> 
  <text>38.0 km</text> 
  </distance>
  </element>
  </row>
  </DistanceMatrixResponse>

Now what I am trying to do is assign the two values fields to variables.

I have pulled this into a Stream IE.

Stream stream = client.OpenRead("http://ho-www/GoogleApiAccess/DistanceMatrix.aspx?origins=" + orilat + "," + orilong + "&destinations=" + destlat + "," + destlong + "&mode=driving'&units=imperial'&language=en'&sensor=false' (http://ho-www/GoogleApiAccess/DistanceMatrix.aspx?origins=" + orilat + "," + orilong + "&destinations=" + destlat + "," + destlong + "&mode=driving%27&units=imperial%27&language=en%27&sensor=false%27)");

Everything I have searched for so far only tells me how to get to the parent elements ie duration and distance but not how to get underneath.

This should be a simple answer but I just cant think it through...

Can any help put me out my misery!

I'm trying to build a report with asp.net report.

If you check this image:

enter image description here

I'm showing a table with tickets and charge. The charge column has these value:

=Fields!Charge.Value

What I want to achieve is only to show the charge value if the ticket value is not null. So as you see in the image, there are 4 tickets visible and I want to show the charge only for those four tickets not all the charges.

Any idea how we can achieve that?

I have ASP.NET MVC app which works good on my local server. When I'm deploying it into Windows Server 2008 Standard in IIS (v7.0) the app is running property (I can see panel to log in), but when I want to log in, I have such error. I have also page Contact and when I want to run it I have the same error.
I add Model.edmx using ADO.NET Entity Data Model.

The code is simple:

In controller:

private ImportEntities Entity = new ImportEntities();
public ActionResult Contact()
    {
        var dane = Entity.Contact.FirstOrDefault();
        return View("Contact",dane);
    }

Connection string in Web.config:

<add name="ImportEntities" connectionString="metadata=res://*/Models.Model.csdl|res://*/Models.Model.ssdl|res://*/Models.Model.msl;
 provider=System.Data.SqlClient;
 provider connection string=&quot;data source=AAA\aaa;
      initial catalog=Database_name;
      integrated security=True;
      MultipleActiveResultSets=True;
      App=EntityFramework&quot;"
 providerName="System.Data.EntityClient" />

The error:

Server Error in '/MyApp' Application.
Line 1: Incorrect syntax near '('. 
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.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '('.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 


Stack Trace: 

[SqlException (0x80131904): Line 1: Incorrect syntax near '('.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
...

What I don't understand: where is that moment when my app use some string connection with '('? I can't install any additional programs to debug it on server and check what is wrong.

Do you have any ideas what and where could be wrong?

I am looking for a way to add an element(Customsections), I have just found a lot of examples about how to read a specific Attribute using ConfigurationManager.GetSection, but what about adding a Section and later elements to it?

well in MSDN in this document (http://msdn.microsoft.com/en-us/library/vstudio/system.configuration.configurationsection(v=vs.100).aspx) in the examples, there is an implementation of a ConfigSection, but again nothing abou adding it programmatically.

I hope can help me I work on a new project they used a Entity framework but not has EDMX or TT files, they map tables like:

     protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new MytableMap());
MyTableMap is:
public class MyTableMap : EntityTypeConfiguration<MyTable>
    {
        public MyTableMap()
        {
            // Primary Key
            this.HasKey(t => t.table_ID);

            // Properties
            this.Property(t => t.tablepro)
                .HasMaxLength(100); ..

And I need add a SP to this project I create something like:

public virtual ObjectResult<SP1Result> SP1(string userid)
        {
            var typeParameter = userid != null ?
           new ObjectParameter("userid", userid) :
           new ObjectParameter("userid", typeof(string));

            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction< SP1Result >("SP1", typeParameter);
        }

I map the SP1Result to entity:

protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Types().Configure(t => t.MapToStoredProcedures());
     modelBuilder.Configurations.Add(new SP1Result());

But I have this issue:

The FunctionImport 'SP1' could not be found in the container 'MyContext'. 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.InvalidOperationException: The FunctionImport 'SP1 could not be found in the container 'MyContext'.

Source Error:

Line 251:           new ObjectParameter("userid", typeof(string));
Line 252:
Line 253:            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<SP1Result>("SP1", typeParameter);
Line 254:        }
Line 255:    }

I hope can you help me how add the SP to my context. Best Regards,

I am new to C# .net but i was using php. i want to achieve the same result as this

$var = $username.$jpwMobileNo;
$pass = sha1(utf8_encode($var ));

so that i can pass the $pass variable to an API that accepts String for $pass how do i achieve this. I have tried this

var pass = userName + no + time + key;
var p = Encoding.UTF8.GetBytes(pass);
var x = sha.ComputeHash(p);
var str = System.Text.Encoding.Default.GetString(x);
var user = new AWsdl.AgencyClient();
var resultAPI = user.GA(userName, no, time, key,str);

but the var str returns as a byte .how do i convert it to a string

My goal is to join two tables by specific IDs using the following within an async command.

result = (from Alpha in db.TABLE1 join Beta in db.TABLE2 on Alpha.
          where Alpha.COLUMN.Equals(query) 
          select new 
          { 
              Alpha.COUMN1, 
              Alpha.COLUMN2,
              Alpha.COLUM3, 
              Beta.COLUMN1
          });

I am getting an async issue at the select level.

My question is how do you use LINQ lambda join commands within an async controller?

I attempted to use ActionResult instead but the other controllers I am using are ASYNC and I would like to continue to use the ASYNC if at all possible.

![enter image description here][1]

Hi,

I want to display data in repeater control like in below images. I have attached outuput of screen shot. I have searched a lot of things in internet but didnt find exactly way to develope. Could anyone please how to implement this task. The data comes from database and bind with repeater contol and display with boxes and arrrow between them. How to draw arrow-boxes and rectagnle in repeater control and how to get xy position of each row and each recrod cell data at run time.

![enter image description here][2]

In test project, I add folder App_GlobalResources. Within that folder I add LocalizedText.resx, LocalizedText.fr.resx, LocalizedText.es.resx and LocalizedText.en.resx. And fill them with with values, eg. Text: Text in specific language. In cshtml, to get them, I use @Resources.LocalizedText.Text.

Problem is - I cannot get it to work properly.. I am switching languages is multiple browsers, all give me the same. If I don't add LocalizedText.en.resx, it allways takes value out of LocalizedText.resx, but with LocalizedText.en.resx, it allways takes values out of it.

Am I missing something? Why doesnt it work properly?

I'm trying to rewrite an old mvc1 application as a vNext app in vs2014. Application authenticates against the company's active directory. Here's a bit of a background to help clarify where my confusion is coming from.

I wrote one app in mvc4 which authenticates the following way: 1. Vs template had account login post action with isValid method 2. I wrote my membership provider and registered it through web.config 3. When I run application isValid is now calling my override that does authentication

Now I'm in vNext and here's what I see 1. Same account and login method except there's some signinmanager and user manager passed into it. I'm yet to see where it's coming from exactly. I suspect it's through startup.cs 2. I see that isValid is replaced with something like Passwordsigninasync which I think I need to override to login the user.

Here's my question how do I make Passwordsigninasync authenticate to our AD? I can go solo and ignore the framework to make it work but I'm sure there's an easy way to do it and I'm just missing some understanding of how plumbing works in vNext. Appreciate any help in the right direction.

I have this property in my model :

[DisplayName("Birth Date")]
public Nullable<System.DateTime> dtnasc { get; set; }

use on view the htmlhelper

 @Html.LabelFor(_ => _.dtnasc)

and receive this error : Nullable object must have a value.

When value of property dtnasc is null, how can we get DisplayName Metadata?