Click here to Skip to main content
15,915,702 members
Home / Discussions / C#
   

C#

 
GeneralRe: Windows Service & SendMessage Pin
mav.northwind4-Mar-05 0:45
mav.northwind4-Mar-05 0:45 
GeneralRe: Windows Service & SendMessage Pin
James Poulose4-Mar-05 2:49
James Poulose4-Mar-05 2:49 
GeneralUsing Word functions Pin
V.3-Mar-05 21:29
professionalV.3-Mar-05 21:29 
GeneralReading ID3 tags with Shell32 Pin
Rob Tomson3-Mar-05 20:44
Rob Tomson3-Mar-05 20:44 
Generalhelp me plz Pin
Member 17782963-Mar-05 20:42
Member 17782963-Mar-05 20:42 
GeneralRe: help me plz Pin
Sebastian Schneider3-Mar-05 22:16
Sebastian Schneider3-Mar-05 22:16 
GeneralRe: help me plz Pin
Member 17782963-Mar-05 22:36
Member 17782963-Mar-05 22:36 
GeneralRe: help me plz Pin
J4amieC3-Mar-05 22:39
J4amieC3-Mar-05 22:39 
The problem here is that there are many things going on all in one line, making it hard to read if you're not all that C# savvy.

Maybe splitting it up could help you.

// Get a reference to the textbox, a call to FindControl must be cast to the right type
TextBox criteriaNumberTextBox = (TextBox)myItem.FindControl("textCriteriaNumber");
// Get the text value of this textbox and parse it to an int
int criteriaNumber = int.Parse(criteriaNumberTextBox .Text);
//Get the first table in the dataset - remember this is zero based
DataTable firstTable = myDataSet.Tables[0];
// here is the -1 stuff.. im ot sure why the -1 is used but its getting the row BEFORE criteriaNumber above
DataRow rowBeforeCriteriaNumber = firstTable.Rows[criteriaNumber-1];
// get the value of the column named "CRITERIA_VALUE" in the above row. Get it as a string and parse it to an int
int criteriaValue = int.Parse(rowBeforeCriteriaNumber["CRITERIA_VALUE"].ToString());
// if criteriaValue is equal to 1 then find a checkbox control named cbCriteriaValue1 in "myItem" and set it to checked
if(criteriaValue == 1)
{
   CheckBox criteriaValue1 = (CheckBox)myItem.FindControl("cbCriteriaValue1");
   criteriaValue1.Checked = true;
}


* disclaimer - the above was typed quickly, I cant guarantee it is compilable in place of the code you pasted.

Im sorry I cant really help you on why this code uses the -1, it seems a bit weird. This is often used to get the last item in an array - as they are zero based the arraylist.count-1 is the last item in the arraylist. However this doesnt appear to be the case with the above code - unless textCriteriaNumber holds the count of an arraylist.

Anyway, maybe commenting the code helps you understand it better.
GeneralRe: question Pin
Member 17782964-Mar-05 1:58
Member 17782964-Mar-05 1:58 
GeneralRe: Pin
Member 17782966-Mar-05 18:47
Member 17782966-Mar-05 18:47 
QuestionHow to dynamically add and use controls at runtime (use custom Pin
oohungoo3-Mar-05 19:56
oohungoo3-Mar-05 19:56 
GeneralProblem with MDI Child form. Pin
Saurabh Mundhra3-Mar-05 19:44
Saurabh Mundhra3-Mar-05 19:44 
GeneralRe: Problem with MDI Child form. Pin
Pushkar Pathak15-Mar-05 20:43
Pushkar Pathak15-Mar-05 20:43 
GeneralRead / Write an Image file Pin
Rob Tomson3-Mar-05 17:20
Rob Tomson3-Mar-05 17:20 
GeneralRe: Read / Write an Image file Pin
Yulianto.3-Mar-05 19:15
Yulianto.3-Mar-05 19:15 
GeneralRe: Read / Write an Image file Pin
Rob Tomson3-Mar-05 19:24
Rob Tomson3-Mar-05 19:24 
GeneralRe: Read / Write an Image file Pin
leppie3-Mar-05 20:36
leppie3-Mar-05 20:36 
GeneralRe: Read / Write an Image file Pin
Rob Tomson3-Mar-05 20:38
Rob Tomson3-Mar-05 20:38 
GeneralRe: Read / Write an Image file Pin
Sebastian Schneider3-Mar-05 22:24
Sebastian Schneider3-Mar-05 22:24 
GeneralRe: Read / Write an Image file Pin
Rob Tomson3-Mar-05 22:32
Rob Tomson3-Mar-05 22:32 
GeneralRe: Read / Write an Image file Pin
Sebastian Schneider3-Mar-05 22:40
Sebastian Schneider3-Mar-05 22:40 
GeneralRe: Read / Write an Image file Pin
Rob Tomson3-Mar-05 23:05
Rob Tomson3-Mar-05 23:05 
GeneralRe: Read / Write an Image file Pin
Sebastian Schneider3-Mar-05 23:08
Sebastian Schneider3-Mar-05 23:08 
Generalunable to see webcontrol on browser Pin
chandtec3-Mar-05 16:41
chandtec3-Mar-05 16:41 
GeneralRe: unable to see webcontrol on browser Pin
Yulianto.3-Mar-05 16:51
Yulianto.3-Mar-05 16:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.