Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9262117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:16:26+00:00 2026-06-18T13:16:26+00:00

I am working on a gridview in ASP.NET c#. In gridview if have 4

  • 0

I am working on a gridview in ASP.NET c#. In gridview if have 4 TextBox in which

1st field - hire/month
2nd field - from date
3rd field - to date
4th field - required machine month

The concept works like this.

The difference between from_date and to_date should be found in terms of month and it should be multiplied with hire/month to get the required_machine_month field. Please help me on this.

I don’t know JavaScript, though I tried my level best by getting the difference in one function and calling the function to another function and multiply it to get the output.

But the JavaScript totally fails and doesn’t seem to work. Please provide me a good script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T13:16:27+00:00Added an answer on June 18, 2026 at 1:16 pm

    Thanks for all your help.. Finally i got the script working. But its a long one. I am posting it below for anyone’s use. If anyone are not clear about. Pls feel free to ask so that i can tell what i have done.

    <script type="text/javascript" language="javascript">
    
    function req_mac_month(numbers,fromDate,toDate,mcMonth)
    {
        //alert("Executed");
        var reqnum=document.getElementById(numbers).value;
        var sdate=document.getElementById(fromDate).value;
        var edate=document.getElementById(toDate).value;
        //var diff=DisplayTo.getMonth() - DisplayFrom.getMonth() + (12 * (DisplayTo.getFullYear() - DisplayFrom.getFullYear()));
        //var diff=Math.ceil((DisplayTo.getTime()-DisplayFrom.getTime())/(1000*60*60*24));
        var day1, day2;
        var month1, month2;
        var year1, year2;
        //var noofmonths;
        day1 = sdate.substring(0, sdate.indexOf("-"));
        month1 = sdate.substring(sdate.indexOf("-") + 1, sdate.lastIndexOf("-"));
        year1 = sdate.substring(sdate.lastIndexOf("-") + 1, sdate.length);
    
        day2 = edate.substring(0, edate.indexOf("-"));
        month2 = edate.substring(edate.indexOf("-") + 1, edate.lastIndexOf("-"));
        year2 = edate.substring(edate.lastIndexOf("-") + 1, edate.length);
    
        date1 = year1 + "/" + month1 + "/" + day1;
        date2 = year2 + "/" + month2 + "/" + day2;
    
        firstDate = Date.parse(date1)
        secondDate = Date.parse(date2)
    
        msPerDay = 24 * 60 * 60 * 1000
    
        dbd = trunc(((Math.round(((secondDate.valueOf() - firstDate.valueOf()) / msPerDay) + 1))/30),4);
                reqmcmonthtotal = dbd * reqnum ;
                document.getElementById(mcMonth).value= reqmcmonthtotal;
        return true;      
    }
    </script>
    

    In the code behind…,

    TextBox rnum = grvps.FooterRow.FindControl("Ftxteditreqnum") as TextBox;
    TextBox fromDate = grvps.FooterRow.FindControl("txtFromDate") as TextBox;
    TextBox toDate = grvps.FooterRow.FindControl("txtEndDate") as TextBox;
    TextBox mcMonth = grvps.FooterRow.FindControl("Ftxteditreqmcmth") as TextBox;
    
    string req_mac_month = string.Format("return req_mac_month('{0}','{1}','{2}','{3}');", rnum.ClientID, fromDate.ClientID, toDate.ClientID, mcMonth.ClientID);
    rnum.Attributes.Add("onchange", req_mac_month);
    fromDate.Attributes.Add("onchange", req_mac_month);
    toDate.Attributes.Add("onchange", req_mac_month);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET GridView which is populated from a SQL Server database. This
I have a working GridView in an ASP.Net webapp which tracks DNS records I
I am working with asp.net 2.0 project. I have a gridview in one of
I am working on an ASP.Net website and have a GridView displaying some data,in
I am working on Gridview in ASP.NET(C#) and have cells that need to have
Im working on asp.net with c#. I have a gridview with templatefield columns, data
I am working on an asp .net project. I have a gridview and on
i am working on a Gridview on ASP .Net. I have a table in
I have an ASP.NET GridView which displays a list of neighborhoods. I wish a
I am working on a GridView in Asp.Net. When initially a the Page Loads,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.