I have to generate a SSRS multiple page report. I have a list "data" and have to do following.
data contains name, salary and address
data[0] = abc,1000,def
data[1] = pqr,2000,xyz
for(int i =0; i<data.Count; i++)
{
//when the value of i is 0 information must be printed on 1st page.
//when value of is 1 information must be printed on 2nd page and so on...
}
What I believe you are looking for is a for loop construct like so:
for (int i = 0; i < data.Length;)
{
int page = ++i;
// Write the data on the page in the int variable above.
}
Related
Please help I have tried to move data from one datagridview column into an array in order to add (calculate) something from it and place it in another column called age. This is what I tried and wanted to see if the data is stored in an array but got a "use of unassigned local variable" error
string data;
int j = 3;
for (int i = 0; i < 10; i++)
{
data = Convert.ToString(dgvData[j, i].Value);
}
MessageBox.Show(data);
The variable data may not have a value assigned to it in the for loop, which would cause the MessageBox to fail. This can be resolved by instantiating data with a default value.
string data = "";
It looks like to me that you are also trying to display each value in the fourth column in the datagridview with MessageBox, so consider moving the MessageBox into the for loop. This could also allow you to move your data variable closer to the call, removing the need for the default value.
int j = 3;
for (int i = 0; i < 10; i++)
{
string data = Convert.ToString(dataGridView1[j, i].Value);
MessageBox.Show(data);
}
The database contains data about movie house(cinema's). The database contains this fields : Name of movie house, Name of movie, start time and date.
I have a problems with additional task. The program should generate a report for each
cinema in the order of the sessions on the specified date.
When I choosing a date in DatePickers, database doesn't show the first movie.
Example:
value of datetimePicker1 = 13.12.2018
value of datetimePicker2 = 16.12.2018
that database show information about 14,15,16.12.2018.
for (int i = 0; i < tableDataGridView.Rows.Count - 1; i++)
{
if (Convert.ToDateTime(tableDataGridView.Rows[i].Cells[4].Value) >= dateTimePicker1.Value
&& Convert.ToDateTime(tableDataGridView.Rows[i].Cells[4].Value) <= dateTimePicker2.Value)
MessageBox.Show(tableDataGridView.Rows[i].Cells[0].Value.ToString() +
" || Movie theater: " + tableDataGridView.Rows[i].Cells[1].Value.ToString() +
" | Movie: " + tableDataGridView.Rows[i].Cells[2].Value.ToString());
}
Please make a change:
I was able to create a similar C# WindowsFormsApplication based on information you have provided and was able to replicate a similar bug and got it resolved with this:
Change:
for (int i = 0; i < tableDataGridView.Rows.Count - 1; i++)
To:
for (int i = 0; i < tableDataGridView.Rows.Count; i++)
Second:
If there is a blank line at the end of GridView, then you may need to add this line to Form1_Load event
tableDataGridView.AllowUserToAddRows = false;
I am trying to pass the id's of textboxes through an array index in c# so that I can get the values from the textboxes but for some reason I am unable to do it. I have almost 500 textboxes and its a data entry form.
This is what I have tried so far:
for(int i=2;i<542;i=i+7)
{
string a = TextBox[i].Text.ToString();
}
Please help me out.
You need to use the function Page.FindControl(), like that:
for (int i = 0; i < 542; i++)
{
string val = Page.FindControl('TextBox' + i.ToString()).Text; // Or use String.Format()
}
Is there any way to keep the value in the arraylist even after the page is loaded because I need the stored values for verifying afterwards.
I tried Http Cookie set also but not able to find it. Pls help
for (int i = 1; i <= random2; i++)
{
// int total_checkbox = Total_Count_Checkbox;
int div = (int)al[i - 1] / 10; //div is the page number of the element
int mod = (int)al[i - 1] % 10; //mod is checkbox number of the element
if (mod == 0) //for checking inf the number comes to be 10
{
div = div - 1;
mod = 10;
}
if (div == 0)
{
LiSt3[mod - 1].Click(); //Clicking for the same page elements
}
else
{
for (int b = 2; b <= div; b++) //checking for the other pages
{
Browser.Click("Saved_Estimates", "Forward_Link_normal");
Thread.Sleep(1000);
}
IList<IWebElement> LiSt4 = driver.FindElements(By.CssSelector(".checkbox.checkbox-success.ng-scope"));
LiSt4[mod - 1].Click(); //clicking for the other page elements
}
Browser.WaitforthePageLoad();
IList<IWebElement> LiSt_of_Names_Summary_List = driver.FindElements(By.CssSelector("span[data-bo-bind='item.Name']"));
IList<IWebElement> LiSt_of_Dates_List = driver.FindElements(By.CssSelector("span[data-bo-bind='item.GeneratedDateString']"));
IList<IWebElement> LiSt_of_Times_List = driver.FindElements(By.CssSelector("span[data-bo-bind='item.GeneratedTimeString']"));
IList<IWebElement> LiSt_of_Last_Day_Worked_List = driver.FindElements(By.CssSelector("div[data-bo-bind='item.LastDayWorkedDateString']"));
IList<IWebElement> LiSt_of_Benifit_Commencement_List = driver.FindElements(By.CssSelector("div[data-bo-bind='item.BenefitCommencementDateString']"));
Browser.WaitforthePageLoad();
LiSt_of_Names_Summary_List_Arraylist.Add(LiSt_of_Names_Summary_List[mod - 1]);
LiSt_of_Dates_List_Arraylist.Add(LiSt_of_Dates_List[mod - 1]);
LiSt_of_Times_List_Arraylist.Add(LiSt_of_Times_List[mod - 1]);
LiSt_of_Last_Day_Worked_List_Arraylist.Add(LiSt_of_Last_Day_Worked_List[mod - 1]);
LiSt_of_Benifit_Commencement_List_Arraylist.Add(LiSt_of_Benifit_Commencement_List[mod - 1]);
if (div != 0)
{
for (int b = 2; b <= div; b++)
{
Browser.Click("Saved_Estimates", "Back_Arrow_normal");
Thread.Sleep(1000);
}
}
}
You can do it easily with the help of session.
Session state enables you to store and retrieve values for a user as
the user navigates ASP.NET pages in a Web application. HTTP is a
stateless protocol. This means that a Web server treats each HTTP
request for a page as an independent request.
For more information for the session go to the following link:
Session
If you want to store any type into the session you just need to assign it to the session like this
ArrayList aryList=new ArrayList();
aryList.Add(Sample);
aryList.Add(Test);
//to store the array list to the session
Session["AryList"] = aryList;
//or if you have a class file then
HttpContext.Current.Session["AryList"] = aryList;
//to get the values from the session
ArrayList aryList= (ArrayList)Session["AryList"];
For more help refer to the following question:
ArrayList Session
Hope it will help you.
Use session variables. You can save a wide variety of information this way, or you can be more elaborate and store information in a database.
You can even use AngularJS and JSON objects etc.. depends on how elaborate you want to get.
I created a dynamic UI that shows each module that the user has added to their selection and all the assessments for that module underneath the module name,
All data is saved in array lists - including objects as textBoxes and labels.
Here's what it looks like:
http://www.4shared.com/photo/fullsize/Ja3jHpRJ/screen1.html
Then the user should enter their marks for each assessments
And the Calculate button should calculate their overall mark for each module
At this stage I am just adding the marks together.
The program works fine when there's only one module added, but when there are more modules it seems to think that a TextBox is empty, even though i fill them all with numbers.
here is my code
private void calculateButton_Click(object sender, EventArgs e)
{
int modLength = dat.ModuleTitle.Count;
int modAsses = 0;
int loopCount = 0;
for (int i = 0; i < modLength; i++)
{
int total = 0;
if ((textboxComputer[loopCount] as TextBox).Text == "")
{
Console.WriteLine("!!!!!");
}
else
{
modAsses = int.Parse(dat.ModuleAssessNum[i].ToString());
for (int y = 0; y < modAsses; y++)
{
total = total + int.Parse((textboxComputer[loopCount] as TextBox).Text.ToString());
loopCount = loopCount + 1;
}
Console.WriteLine(total);
}
}
}
When i add two or more modules it displays the "!!!!!" message, but calculates the mark for the first module added.
here's some output
http://www.4shared.com/photo/fullsize/PlY29BMQ/screen2.html
You need to make sure that the code that creates the extra dynamic elements on screen is being called as part of the page load, so that then the viewstate is inserted back into the elements and can be read back out by your code.
there is something wrong with your code, probably a lot wrong(except the names of your variables).
Take a look at your loopCount variable - you will only conditionally change it in your loop but you always use it at the start of the loop(where you do textboxComputer[loopCount]).
So what's the expected behavior of that? The first time you get in to the loop if you go to your 'else' part you may print the total as you say but you also change the loopCount variable, once you get to the Console.WriteLine("!!!!!"); you never change it again - so your iterations will behave the same.