|
-
March 4th, 2009, 07:33 AM
#3
Re: [2005]Update Connection String
I would like to take a Chance to Thank you for what you have done for me. The Code looks good. The Code looks like this
Code:
protected void setupGrid()
{
if (((int)Session["numCycles"]) > 0)
{
UltraWebGrid cycleGrid = ultraGridCycles;
int numCols = 0; //Number of Colums
int numRows = 0; //Number of Rows
//If the Sessions are Greater than 13 , Make
//the Columns to be 13 else keep the supplied value for the Columns
if (((int)Session["numCycles"]) >= 13)
{
numCols = 13;
}
else
{ //Keep the Columns as they are
numCols = ((int)Session["numCycles"]);
}
/*This one is used for the Row not the Column like the above one*/
//Divide the Session variable Value by 13, the Returned
//number is Checked if its 0 if that is true the First Statement get executed
//else the second -->
//I suppose this was meant to check the zero, because you cant divide by zero
if ((((int)Session["numCycles"]) % 13) == 0)
{
//Assign the value of a Session Varable that is Devided by 13
numRows = (int)(((int)Session["numCycles"]) / 13);
}
else
{
//Assign the value of a session variable and Divide it by 13
//add a on top of it.
numRows = (int)((((int)Session["numCycles"]) / 13) + 1);
}
//Change the Height of the Grid
cycleGrid.Height = Unit.Pixel(20 * numRows + 6);
/*'''''''''''''''''''''''''''''''''''''''''''
* For the Column
* ''''''''''''''''''''''''''''''''''''''''''*/
/*This is a For Loop. We First declare
* the integer and initialize it to 0 and the second one is
* the expression, we say, as long as the number of [i] variable are less than the number of columns
* then increase the value of i
*/
for (int i = 0; i < numCols; i++)
{ //Create an object of a class Ultracolumn that represents the Column
UltraGridColumn col = new UltraGridColumn(true);
//adjust the Width of the Column
col.Width = Unit.Pixel(10);
//Its a Unique String in a Gridview
col.Key = i.ToString();
//Now we are adding Columns in the Gridview by passing the Column object.
cycleGrid.Columns.Add(col);
}
/*'''''''''''''''''''''''''''''''''''''''''''
* For the Rows
* ''''''''''''''''''''''''''''''''''''''''''*/
/*Here we are using the For loop,
* First declare and initializing the variable i
* and while the variable i is less than the number of rows then increase
* the value of i */
for (int i = 1; i <= numRows; i++)
{
//Create an object of a Class UltragridRow and initialize it
UltraGridRow row = new UltraGridRow(true);
//Assign a unique key of a row
row.Key = i.ToString();
/*'''''''''''''''''''''''''''''''''''''''''''
* For the Cell
* ''''''''''''''''''''''''''''''''''''''''''*/
/*Declare a Variable of integer "j" and assign it a value of "1"
* and as long as the value of J is less that and equal to number of Columns
* then increament the value of a variable J
*/
for (int j = 1; j <= numCols; j++)
{
//Create an object of a class UltraGridCell and initialize it.
UltraGridCell cell = new UltraGridCell(true);
//adjust the gridproperties
cell.Style.HorizontalAlign = HorizontalAlign.Center;
//adjust the gridproperties
cell.Style.Padding.Left = 0;
//adjust the gridproperties
cell.Style.Padding.Top = 0;
//adjust the gridproperties
cell.Style.Padding.Bottom = 0;
//adjust the gridproperties
cell.Style.Padding.Right = 0;
//adjust the gridproperties
//Adjust the Cell Value to Integer 13 mutiply by number of rows -1 ajd pluss number of Columns
cell.Value = (int)((13 * (i - 1)) + j);
/*If 13 multiply by number of rows -1 one plus number of Columns
* is greateer than the session variable then set the value of that cell to null */
if (((13 * (i - 1)) + j) > ((int)Session["numCycles"]))
{
cell.Value = null;
cell.Style.BackColor = System.Drawing.Color.Gray;
cell.AllowEditing = AllowEditing.No;
}
//add the cells to the Grid
row.Cells.Add(cell);
}
cycleGrid.Rows.Add(row);
}
/*After the Grid has been Populated, let us remove some of the cells
* using the Following code
*/
ArrayList array = (ArrayList)Disable_Grid();
//Count the Number of rows in a gridview and initialize the integer with those values
int u = cycleGrid.Rows.Count;
/*Another For Loop,First we declare an Interger variable "i" and
* initialize it with "0" and as long as the variable i is less than the number of
* rows in a gridview increament the variable i
*/
for (int i = 0; i < cycleGrid.Rows.Count; i++)
{
/*Creating an object of a Class GridViewRow "g" and
* passing the Value a Variable i that has
* been checked as less than the Value of the Rows
*/
UltraGridRow g = cycleGrid.Rows[i];
/*Another For Loop. Initialization of a newly declared variable
* j to "0" and as long as the number of Cells are less than the variable J then increase the Value of a
* variable J
*/
for (int j = 0; j < g.Cells.Count; j++)
{
/*for Loop in a For loop. Declare an Integer "p" and Assign
* 0 to it and as long as the number of p variable are
* less than the number of indexes in the array list variable
if its true the value of P is incremented by 1*/
for (int p = 0; p < array.Count; p++)
{
/*A String is Declared and is Assigned a value of
* of a cell indexed by the variable J that is not supposed greater than
* the number of cells in a grid
*/
string txt = g.Cells[j].Text;
/*if then value in the text is equal to the value of the array
* make the cell invisible*/
//int m = array.Count;
if (txt != array[p].ToString())
{
/*The I is representing the Rows and the J is representing the Cells
*/
cycleGrid.Rows[i].Cells[j].Style.ForeColor = System.Drawing.Color.DarkGray;
cycleGrid.Rows[i].Cells[j].Style.ForeColor = System.Drawing.Color.DarkGray;
cycleGrid.Rows[i].Cells[j].AllowEditing = AllowEditing.No;
//this.cycleGrid.Rows[0].Cells[0].Activation = Activation.Disabled;
cycleGrid.Rows[i].Cells[j].Activated = false;
}
else
{
cycleGrid.Rows[i].Cells[j].Style.ForeColor = System.Drawing.Color.Black;
cycleGrid.Rows[i].Cells[j].Style.BackColor = System.Drawing.Color.White;
cycleGrid.Rows[i].Cells[j].Style.Font.Bold = true;
}
}
}
}
}
}
The grey Part make it look as if its disabled. Am using Infragistic Control Ultragridweb, so i could not Disable the cells there. Do you have any suggestions there?
Thank you for your help
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|