Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Mathi Mani

@Mathi Mani
About
Posts
15
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Problem with connectionstrings
    M Mathi Mani

    Why are you getting connectionstring by index instead of getting them by using their name?

    Visual Basic csharp visual-studio security help question

  • Using Image Data type for a variable is giving error
    M Mathi Mani

    Since no code is posted, there is no way to see how you are storing and/or retrieving image. This CP article explains the steps. Please take a look. Storing and Retrieving Images from SQL Server Using Strored Procedures and C#[^]

    Database help

  • Converting Array To Dictionary
    M Mathi Mani

    Just add a where clause in your code like this:

    Dictionary<int, Product> productlist = products.Where(b => b != null).ToDictionary(p => p.ProductSkew, p => p);

    This will ignore all the null products and convert the rest into dictionary.

    C# data-structures help

  • Order by by using levels using sql Script
    M Mathi Mani

    Let us assume that you have following data in Employee table

    Id Name Level
    1 zzzz 1
    2 nnnn 1
    3 dddd 1
    4 df 2
    5 bc 2
    6 za 2
    7 az 2
    8 ff 2
    9 ef 2

    and these data in EmployeeRelationShip table

    Id EmployeeId ManagerId
    1 4 1
    2 5 1
    3 6 2
    4 7 2
    5 8 3
    6 9 3

    This query will give results ordered by Manager Name and then by Employee Name:

    select e.Name as ManagerName, b.Name as EmpName from
    EmployeeRelationShip r inner join
    Employee e on e.Id = r.ManagerId
    inner join Employee b on b.Id = r.EmployeeId
    order by e.Name, b.Name

    And the output will be:

    ManagerName EmpName
    dddd ff
    dddd ef
    nnnn za
    nnnn az
    zzzz df
    zzzz bc

    Hope this provides an idea for you to solve your problem.

    Database database tools help question

  • Adding Objects To Session
    M Mathi Mani

    The issue is where you add the accts which is a List<Account> to the session. These two lines of code always replace whatever object present in Session["acctObjects"]

    accts.Add(acct);
    Session["acctObjects"] = accts;

    To avoid the overwrite, whenever you want to add a Account to List<Account> stored in session, get the List from session, add new Account to that list and store it back to session. Here is how you can do it.

    if (Session["acctObjects"] != null)
    accts = (List<acct>)Session["acctObjects"];
    accts.Add(acct);
    Session["acctObjects"] = accts;

    ASP.NET help

  • Gridview with full-screen editing question
    M Mathi Mani

    The event you are looking for is RowDataBound. Add it to your gridview like this:

    And write your code in that event handler (gvItems_RowDataBound).

    ASP.NET question database csharp html announcement

  • Nested Select queries i main select query LINQ
    M Mathi Mani

    Hi, Here is the link which shows how to get count from LINQ query. http://stackoverflow.com/questions/3853010/get-item-count-of-a-list-using-linq[^] Here is link that shows how to query Datatable using LINQ: Working with LINQ to Entities & LINQ to DataTable[^]

    C# database csharp sql-server linq com

  • How to not display the a row based on a condition.
    M Mathi Mani

    If that row is not required, then filter it while getting the data from your data source. So you can avoid all these at code level in C#.

    C# question css graphics tutorial

  • Trying to make a DataGridView field a color if a condition is met.
    M Mathi Mani

    Refere this question for changing the color of a grid row based on some condition. The code is in Vb.Net but you can get the idea. How Can I Change A Rows Backcolour Based On The Value In The First Cell Of The Same Row[^]

    C# help

  • Trying to make a DataGridView field a color if a condition is met.
    M Mathi Mani

    When you want the row to be colored? Change the if condition based on that. It should work.

    C# help

  • Trying to make a DataGridView field a color if a condition is met.
    M Mathi Mani

    May be the value ActualFTE is not greater than 1.25, as per your condition.

       if (ActualFTE > 1.25)
       {
          e.Row.BackColor = Color.Red;
        }
    

    So the color will not be changed.

    C# help

  • Trying to make a DataGridView field a color if a condition is met.
    M Mathi Mani

    Just to make sure everything is fine, try hardcoding the value and see if you still get the error.

    decimal ActualFTE=Convert.ToDecimal("0.9500");

    If this works without exception, then you can be sure, the problem is with the expression e.Row.Cells[5].Text. This expression you use should return some string (like your value 0.9500) that can be converted to decimal for the conversion to work without exception.

    C# help

  • Trying to make a DataGridView field a color if a condition is met.
    M Mathi Mani

    decimal ActualFTE=Convert.ToDecimal(e.Row.Cells[5].Text);
    if (ActualFTE > 1.25)

    In the above code check whether e.Row.Cells[5].Text returns data that can be converted to decimal. Or add ToString() at the end and see if it helps.

    decimal ActualFTE=Convert.ToDecimal(e.Row.Cells[5].Text.ToString());

    C# help

  • Trying to make a DataGridView field a color if a condition is met.
    M Mathi Mani

    Can you post what value is coming in

    e.Row.Cells[5].Text

    It will give a better idea on what we are dealing with.

    C# help

  • Trying to make a DataGridView field a color if a condition is met.
    M Mathi Mani

    The error message says it clearly. You are trying to covert a decimal to int. Change your stament like below and try.

    decimal ActualFTE=Convert.ToDecimal(e.Row.Cells[5].Text);
    if (ActualFTE > 1.25)

    C# help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups