4
Answers

Problem in calling Linq method which return group by result on page load

Ajay Kumar

Ajay Kumar

14y
3.4k
1

Hi,
I hv method in class file and i need to call it on page load...I just want to knw what shud be exact return type  here...

 
public static void GetPaymentGroupBy()
{
DataClasses1DataContext obj = new DataClasses1DataContext();
var query = (from pay in obj.GetTable<Payplan_Installment>()
group pay.Frequency by
new
{
pay.InstallmentAmount,
pay.PaymentMode,
pay.PlanStatus
}
into details
select details);
}
 
===
I m calling on page load like this:
dataGridView1.DataSource =
DataClasses1DataContext.GetPaymentGroupBy();
please help me,it is very urgent
Thanks in advance
Answers (4)
0
Vulpes
NA 98.3k 1.5m 12y
Not sure where your post has gone on this but, if you need to control the 3rd party application depending on the selection of some specification on the form, then the easiest way to do it would be to pass the application command line arguments if it's been written to accept them.

You can pass the arguments in the Process.Start method. For example:

   string arguments = "1 abc"; // separate arguments by spaces

   System.Diagnostics.Process.Start("someapp.exe", arguments);

If  the application doesn't accept command line arguments, then you might be able to use SendKeys.Send to send it some keystrokes - for example to open a menu and select an option. This isn't as easy as it sounds since there may be synchronization difficulties and you may need to build in delays between sending the keystrokes to overcome these. Check out the MSDN docs here:

http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx 


0
Vulpes
NA 98.3k 1.5m 12y
Well, what's usually done is to put a button on the form, which when pressed, launches the external application:

private button1_Click(object sender, EventArgs e)
{
   System.Diagnostics.Process.Start("someapp.exe");
}

If you wanted the form to display and then the external application to launch automatically, you could do it by handling the form's Shown event:

private void Form1_Shown(object sender, EventArgs e)
{
   System.Diagnostics.Process.Start("someapp.exe");