JerryShaw 46 Posting Pro in Training

Glad you figured it out, and I apologize for not telling you about that. I was sidetracked with another DaniWeb'er and forgot to get that information to you.
Again, Sorry
//Jerry

JerryShaw 46 Posting Pro in Training

dickersonka,
Interesting approach. Never had to do that.
A static class can not have a constructor, therefore it is automatically a global singleton by nature of the beast.

I have a static class in a very large plugin based application. All of the plugins (dll files), and the main app have access to it without any instantiation. All of the classes can change properties, run its methods, etc. with no problem. Just interested in your suggested approach, and what the pros and cons are over a static class.

// Jerry

JerryShaw 46 Posting Pro in Training

try making the class static as well:
public static class GlobalVariables

JerryShaw 46 Posting Pro in Training

try this:

double AverageCalc = 0;
            if (dataGridView1.Rows.Count > 0)
            {
                foreach (DataGridViewRow row in datagridview.Rows)
                {
                    double average;
                    if (double.TryParse(row.Cells[2].Value.ToString(), out average))
                        AverageCalc += average;
                }
                AverageCalc /= datagridview.Rows.Count;
            }
            txtAverage.Text = AverageCalc.ToString();

BTW: You didn't post the error you were getting, only that it is broke

JerryShaw 46 Posting Pro in Training

Welcome, its nice to be able to help and work on something other than the complex code I typically deal with everyday in my job.

Yes you can have multiple forms and navigate between them using buttons, etc.

Have fun,
// Jerry

JooClops commented: Can't stop thanking You +1
JerryShaw 46 Posting Pro in Training

MS Visual Studio

JerryShaw 46 Posting Pro in Training

Okay,
You wanted lines... You got Lines :)
Add this Paint event handler to your panel's Paint event.

private void panel_Paint(object sender, PaintEventArgs e)
        {
            int rowLineOffset = panel.Height / 3;
            int colLineOffset = panel.Width / 3;
            Pen pen = new Pen(Brushes.Red);
            pen.Width = 3;
            pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            for (int i = 1; i < 3; i++)
            {
                e.Graphics.DrawLine(pen, new Point(3, i * rowLineOffset - i * 2), new Point(panel.Width -3, i * rowLineOffset - i * 2));
                e.Graphics.DrawLine(pen, new Point(i * colLineOffset - i * 2, 3), new Point(i * colLineOffset - i * 2, panel.Height -3));
            }
            pen.Dispose();
        }
JerryShaw 46 Posting Pro in Training

I am thinking that isMkvTest is null.
You can test for that by changing:

if (isMkvTest.Trim().Length != 0)

change to:

if( !string.IsNullOrEmpty( isMkvTest ) )

As for using the Visual Studio Debugger. Simple... Left click the margin to the left of the code you want as a break point. You should get a red ball to appear, and the text will be back-lit with red. Press the F5 key to start debugging. Next, when it gets to that line, step into it with F11, or through it with F10. You can hover the mouse of an object to get its value, and you will see lots of other options once you start using the debugging tools.
If you do not have Visual Studio, then get the free express version from MSDN, and use it to debug your program.

// Jerry

JerryShaw 46 Posting Pro in Training

lbl.ForeColor = lbl.AllowDrop ? Color.Blue : Color.Black;
That is what we call short cut code. It comes from the old days when we had the IIF statement. your assumption is correct, the first segment must equate to a boolean expression, the second is the value to deliver when the boolean is true. The third segment is the else value.

Passes... This is a triggered kill point. If the validity checks fail after nine attempts, then just leave the target blank and move on. Without this, you could find yourself in an endless loop, or atleast a very long running loop.
Most of the time, the PassChecks() will return true, and it only goes into the loop when a conflict is detected.
Anytime you have a loop construct ALWAYS give your code a way of timing out or escaping the loop. If it came out of the loop and the trigger point was reached, then blank the text and array for this position.

How the code works is that if the randomizer gave us a value in range, we start testing (makes sure that the value being placed will not violate Soduko rules off the bat, the job of PassChecks). If it fails the test, then we give it another number to try. Stop trying after 9 passes.

BTW, to increase or decrease the difficulty level of the game, you can just set the rd.Next in the line above this section (currently 18).
This …

JerryShaw 46 Posting Pro in Training

Bob,

Look in the directory:
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
for the AdventureWorks_Data.mdf file.

If you do not already have the Sql Server Management Studio Express, then I recommend you download it from MSDN (its free).

If the file exists in that directory, then use SSMS to see if the database exists as a registered database. If not, then try attaching it using the options on the Database node.

I believe that you can also get the script from MSDN (or already on your hard-drive for re-creating that database).

Let me know how it goes.
BTW: a DAL is whatever you want to make of it. It is not something fancy or complicated. If you want to learn more about it, let me know.

// Jerry

JerryShaw 46 Posting Pro in Training

Yes Try..Catch and Try..Finally are basic code blocks available in all projects for c#.

I will find another way to send you the zip file. I made a few changes so that the numbers are centered in the panel cell, and a randomizer populates some of the cells. A future option to consider is to allow the user to select the difficulty level so that you can control the number of values the computer places on the screen.

I think you will find it interesting.

// Jerry

JerryShaw 46 Posting Pro in Training

UPDATE dbo.Employee
SET TAX = ( 1.25 * (Convert(int,substring(Salary,1,len(Salary)-1) * 1000 ))
WHERE Salary > '30K' OR len(Salary > 3)

JerryShaw 46 Posting Pro in Training

Do you mean that your data actually contains the charcter 'K' in the salary value ?
(that would be ugly)
Assuming that it is true:

UPDATE dbo.Employee
SET TAX = ( 1.25 * Convert(int,substring(Salary,1,len(Salary)-1) )
WHERE Salary > '30K'

**free handed, so perform some tests on a temp table before using it on a real system.

// Jerry

JerryShaw 46 Posting Pro in Training

Have you used debug to trace to the actual line that crashes ?
I would venture to guess that it is at the line:
string isMkv = isMkvTest.Substring(isMkvTest.LastIndexOf(':'));

There is no guarantee that isMkvTest is instantiated.
Just because you are asking it to readline, does not mean that there is a non null value returned. Anyway, best bet is to set a break point at the top of the readStreams method, and step to the problem... Something is null that should not be.

// Jerry

JerryShaw 46 Posting Pro in Training

Is this a duplicate ? I think you posted this earlier, and I sent you some code to use the DataGridView instead of the DataGrid component.

// Jerry

JerryShaw 46 Posting Pro in Training

Does the text file contain delimiters other than CRLF ?
If not, then you will have to consider using line based parsing.
Line 0 = CDid
Line 1= Artist
Etc.

If you can post some code, someone (if not me) will come along and give you some feedback.

// Jerry

JerryShaw 46 Posting Pro in Training

Bob,

I take it you are using the Data Source Wizard crap in VS2008.
Some people get along with it, but I have been bitten way too many times, and I simply refuse to use it. It has the potential to lose databases, and IMO it is more trouble than it is worth.

I see a lot of new students accessing MDF files through VS, and most of them end up with some issue at the end of the day. Some of them get tragic results.

Personally, I prefer to build my own DAL (Data Access Layer) class and let it deal with data the way I want to.... not the way that wizard does it. When comparing code between my DAL, and the horrendous, bloated, useless class that VS creates for you... you will see why most people avoid it.

Sorry for venting, but you are not the first person to get bit by VS's Database wizard class generator. If that is what you are using.

If the database is indeed still in the SQL Server, then blow away the class that VS built for you as the database designer stuff. Delete it from the project, and see if you can get back to the database using traditional SQL___ methods.

Good luck
// Jerry

JerryShaw 46 Posting Pro in Training

Okay

Got the project.
Below is the Clear button event handler.
An explanation follows.

private void btnclr_Click(object sender, EventArgs e)
        {
            Label lbl;
            int num;
            string tag;
            try
            {
                Enabled = false;
                this.Cursor = Cursors.WaitCursor;
                panel.SuspendLayout();
                foreach (Control cntrl in panel.Controls)
                {
                    lbl = cntrl as Label;
                    if (lbl != null)
                    {
                        tag = lbl.Tag as string;
                        num = 1 + Convert.ToInt32(tag.Split('|')[1]);
                        lbl.Text = num.ToString();
                    }
                }
                for (int i = 0; i < 9; i++)
                    for (int j = 0; j < 9; j++)
                        _mat[i, j] = i;
            }
            finally
            {
                this.Cursor = Cursors.Default;
                Enabled = true;
                panel.ResumeLayout(true);
            }
        }

First it declares a few working variables.
Next we place the code into a Try...finally, for a number of reasons, but primarily because we are going to set the cursor to a waitCursor ( because working with longer iterations should do this).
And we are going to Disable the form by setting the Enable to false (lock the user out so they can not mess with what we are doing).
Disable the layout panel so that it will not flicker and slow us down with its internal rendering.
and finally because we want to make sure all things will be turned back on no matter what happens in the code.

Inside of the working code, we iterate through all of the labels of interest within the layout panel. We get their j value from their Tag, add one to it …

JooClops commented: The most Awesome guy in the world<<<< +1
JerryShaw 46 Posting Pro in Training

Bob,

Sorry for the delay, been busy.

Okay, the programmers haven example is using the old DataGrid component that has been replaced with the newer DataGridView component in VS2005 and higher. The old one is available by adding it to the toolbox, but instead of telling you more about that, I will show you how to use the DataGridView.

First drag a DataSet component from the toolbox onto the form.
Name it "ds" for now.
Now drag a DataGridView component onto the form. For now, just ignore its wizard and use the untyped option. Name it "dgDetails".

private void btnLoadData_Click(object sender, System.EventArgs e)
{
    string connectionString = "server=P-III; database=programmersheaven; uid=sa; pwd=;";
    SqlConnection conn = new SqlConnection(connectionString);
    string cmdString = "SELECT * FROM article";
    SqlDataAdapter dataAdapter = new SqlDataAdapter(cmdString, conn);
    //DataSet ds = new DataSet(); 
    dataAdapter.Fill(ds, "article");
    //dgDetails.SetDataBinding(ds, "article");
   dgDetails.DataSource = ds;
   dgDetails.DataMember = ds.Tables[0].TableName;
}

Now if you want to know more about the BindingSource, I will give you a short definition, and you will need to study it further.

The BindingSource can be dropped onto your form, and instead of setting the DataGridView DataSource to the adapter like we did above, set it to the BindingSource in the designer (IDE).
Set the BindingSource.DataSource and DataMember like we did above to the DataSet you dropped (DataMember goes to the table in the dataset which you can manually create in the IDE).

Now the BindingSource offers a few advantages, you can assign …

JerryShaw 46 Posting Pro in Training

JooClops,

Hope you live in a safe area of Israel.

It appears that you just copy paste'd the console methods into the Check button handler. That won't work.

You have three methods that are used to check faulty entries:
Col, Row, Square
and a single method used by each for the actual validation.
Rewrite them as individual methods (IOW not inside the Check button), and call them accordingly.

So, lets start with the isvalid method: Create it as its own method (not embedded within another method.)

private bool IsValid(int[] ar)
        {
            for (int i = 0; i < ar.Length; i++)
            {
                for (int j = 0; j < ar.Length; j++)
                    if ((j != i) && (ar[i] == ar[j]))
                        return false;
            } 
            return true;
        }

Changed to a private (non static) method using Camel-Case naming convention.
Modified to account for arrays less than 9 in length.

Next we need to add the row check method:

private bool CheckRow(int rownum)
        {
            int[] ar = new int[9];
            for (int j = 0; j < _mat.GetLength(1); j++)
                ar[j] = _mat[rownum, j];
            return IsValid(ar);
        }

Changed to a private (non static) method using a new Name.
Using the private _mat instead of passing it as a variable.
Return whatever IsValid gives you instead of evaluating it.

The remaining two methods are similar in changes:

private bool CheckCol(int colnum)
        {
            int[] ar = new int[9];
            for (int i = 0; i …
JerryShaw 46 Posting Pro in Training

The dgDetails is a BindingSource.
The DataGridView is most likely set to use this bindingsource so that when the bindingsource sets the binding to the dataset its datamember of most lilkey the first datatable is then displayed in the gridview.

// Jerry

JerryShaw 46 Posting Pro in Training

You can set the Modifier property of the DataGridView in the second dialog box to public. Then if the dialog result is Ok, then you can access the selected row of the DataGridView from your first dialog.

Hope this helps
// Jerry

JerryShaw 46 Posting Pro in Training

Another approach you may want to explore is the free version of Advanced Installer http://www.advancedinstaller.com/
I used the free version for a few months, and have since upgraded to the full Enterprise version.

JerryShaw 46 Posting Pro in Training

What are the possible "Bet Types" ?
NumericUpDown works on numeric values. Is this bet type a enumeration ? or a real value (like an integer) ?

IOW, what are you expecting to place in the NumericUpDown.Value property ?

JerryShaw 46 Posting Pro in Training

ddanbe,

That line occurs because of the flat style being standard. During the click, the component base uses the drop effect which drops the top border into view.
Avoid that in the onPaint (or elsewhere) so that it does not exhibit the drop on click effect.

base.FlatStyle = FlatStyle.Flat;

// Jerry

JerryShaw 46 Posting Pro in Training

Bob,
What are you referring to, there is no dgDetails class for that component.

What are you trying to get to (DGV elements) and maybe I can help.

// Jerry

JerryShaw 46 Posting Pro in Training

You need to move the declaration to the top of the class.

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
      
       // Private class declarations
       [B]private int[,] _mat new int[9, 9];[/B]

        public Form1()
        {
            InitializeComponent();
        }
...

When declared inside the class but outside of any methods it is a class variable. Any method within the class can access it.
Use public variables when classes outside of this class need to have access to it. You do not have any of those yet.

Also something to know is that any method declared inside of a method is only accessable from within the method it is declared. Also, the instance will die the moment the method exits.

BTW, what country are you residing ? just curious as to the time difference. I am in Idaho USA

// Jerry

JerryShaw 46 Posting Pro in Training

Okay,

No problem on the newB questions, everyone is a NewB at some point.

Does not look like you need to convert the text to integer, the (i+1) that you are assigning to the Text, is already an integer, so just set the array value to that value: mat[i,j] = i +1;

"1.once the label is changed ,how can i change it in tthe Matrix , i need to get it's place,which i can't think of a way to do it :"
For this, I will show you another little trick called Tag.
All components (well 99% of them) have a Tag property of type object. You can store anything you want in there. For this (and to keep it simple) lets place the address in this property as a string:

lbl.Tag = string.Format("{0}|{1}",i,j);
// use of the pipe character as a delimiter is just my choice, you can use any charcter.

Now to use this you will need to split the address back out and convert them back to Integer.

private void label1_DragDrop(object sender, DragEventArgs e)
        {
            Label target = sender as Label;
            Button btn = e.Data.GetData(typeof(Button)) as Button;
            target.Text = btn.Text;
            string address = (string)target.Tag;
            int i = Convert.Int32(address.Split('|')[0]);
            int j = Convert.Int32(address.Split('|')[1]);
            mat[i,j] = Convert.Int32(target.Text);
        }

BTW: you will learn this later, but code formatting will help your code stand out. For example all class private variables should start with an underscore (if you wish to follow the Microsoft coding …

Antenka commented: Great job :) Plenty of work you did!!! +2
JerryShaw 46 Posting Pro in Training

Looks like you are making progress.

You can create a single event handler for the label object to do this, however you could just as easily tag the event into the Drag Drop onto the label.

If you want to allow the user to actually type values into the object, you should replace the label component(s) with a TextBox component.

To turn a string from the label or TextBox (any string) into an integer you can use the parsing methods of that type.

int i;
            string someValue = "123";
            if (Int32.TryParse(someValue, out i))
            {
                // i now = 123
            }
            else
                MessageBox.Show("Invalid value, must be numeric");

To control the size of your labels, you should set the AutoSize property to false.

// Jerry

JerryShaw 46 Posting Pro in Training

The container should be the table (panel) not "this".
So instead of creating the labels and adding them to this

this.Controls.Add(lbl);

use

panel1.Controls.Add(lbl);

// Jerry

ddanbe commented: Nice job! +4
JerryShaw 46 Posting Pro in Training

If you are looking to pull something from the clipboard, then use the Clipboard static class. Something like this (more methods are available)

if (Clipboard.ContainsText())
        {
            string data = Clipboard.GetText();
        }
JerryShaw 46 Posting Pro in Training

Which "table" component are you using ?
Is this a DataGridView ? ListBox ? or something else ?

// Jerry

JerryShaw 46 Posting Pro in Training

The Label was purely to help you experience and play with Drag & Drop (concept stuff).
Not being a Sudoko player myself, I am not all that familiar with the game board.
If I were building it, I would use graphical design methods, but those are (for now) a bit more advanced than you should tackle.

To generate 81 labels, you can create and add them at runtime within a loop. You need to perform a few steps for this.
Primarily you will create them in a for..loop, and add them to the Main form, or a panel (or some other container).

Here is a quick and dirty way, you will have to manage your own location and size values:

To add this to your code, select the form, and assign an event handler for the Load event. In the code snipet below, I just create 4 new labels, and position them on the form, add them to the container (in this case the form itself).
Assign the event handler like you did in the Label component as you did earlier.

private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 4; i++)
            {
                Label lbl = new Label();
                lbl.Text = i.ToString();
                lbl.Location = new Point( 30, 70 + (i * 20) );
                lbl.Size = new Size(label1.Width, label1.Height);
                lbl.DragDrop += label1_DragDrop;
                lbl.DragOver += label1_DragOver;
                lbl.AllowDrop = true;
                this.Controls.Add(lbl);
            }
        }

This being done, now you need to change …

JerryShaw 46 Posting Pro in Training

<<Does the strong Typed column field names HAVE to match the names in the DataAdaptor>>

The matching column names of a typed datatable will get populated, and the others (non-matching) will not get populated.

All column names must be unique, and they do not contain the alias prefix.

You can manually create the typed datatable and populate it from the adapter. Columns in a typed datatable do not need to be in the same order as what is returned from the server.

OdbcConnection DbConnection = new OdbcConnection("Provider=MSDASQL.1;DSN=Vision Data;UID=user;PWD=pswd");

             string strSQL = "SELECT TR.Tran_num, AM.Acct_no, AM.Cust_type ”
            + "FROM artransaction  TR "
            + "INNER JOIN armaster  AM ON TR.Acct_no = AM.Acct_no "
            + "WHERE TR.Profit_no = 1 and TR.Tran_num = 842049";

            OdbcDataAdapter da = new  OdbcDataAdapter(strSQL, DbConnection);
  
            DataTable untypedDT = new DataTable();
            da.Fill(untypedDT);
            
            foreach(DataRow row in untypedDT.Rows)
            {
                MessageBox.Show(untypedDT[0].ToString());
            }
JerryShaw 46 Posting Pro in Training

Good, I am glad you have decided not to cheat.
On the otherhand, reviewing someones code is the way most everyone learns.
Okay, as for the buttons, I assume you are using Visual Studio 2008 Express, if not get an IDE, SharpDev, Mono or VS2008e (all are free).

Here is some code to get you started:
Create a Windows application, and spread out the form so it can fit the 9 buttons along the bottom of the form.

For now, I dragged a Label component from the toolbox onto the center of the screen. This is the component we will drop the buttons onto. You will want to use your own target component(s) once you understand the concept. Set the AllowDrop property in the property editor of the label to true (means yes, I want this component to allow things to be dropped on it).

Select the first button (button1 in this case), and in the property editor, select the event (lightening bolt) tab, and find the onMouseMove event handler. Type in buttonMouseMove (or whatever you desire). Press enter and let it create the event handler code. Now go back to the form and select all of the other buttons, and drop down the onMouseMove property combobox, and select the buttonMouseMove handler you just created. This ties all of the buttons to the same event handler (just makes it easier than creating and duplicating 9 handlers).

Next you want to force the button …

JerryShaw 46 Posting Pro in Training
JerryShaw 46 Posting Pro in Training

I would imagine that you can even find some example Sudoko (or similar games) code on Code Project or elsewhere on the net.

JerryShaw 46 Posting Pro in Training

I don't think you really need to have an array of buttons for this project.
Instead set the table to allow drop that way it will allow you to use the drag drop events on the table.
Then on the Mouse Move event of the buttons, start a drag operation. Let the table handle the drag events, and handle the button that is being dropped on the table.

There are plenty of examples of drag drop on the net, and you should be able to see how to do each of these functions, however if you get in over your head, there are folks here that can help.

// Jerry

JerryShaw 46 Posting Pro in Training

IMO you should use an XML file to store extra information. I don't particularly like the Settings way in dotnet simply because it has some ugly side effects. The settings data is stored in the Documents and Settings area, and if you move the application to a different directory, you will leave trash data behind in the original directory, and the settings data does not follow to the new directory. Second, If you decide to change a setting name in the future, you have another problem of how to upgrade their existing settings without losing data.
After being bit a few times with Settings, I never use them anymore. XML is easy to use and expand.
But if I have not convinced you to avoid Settings, then look in the designer code of your project and see how the settings are being initialized, and that should let you perform the same steps at run time.

JerryShaw 46 Posting Pro in Training

Try using a switch( var.Length ) construct. That should limit you to ten or so case statements.

JerryShaw 46 Posting Pro in Training

Hi! I need help with something that is IMHO a pretty simple matter: i need to make a program that uses wiindows forms in the way that there is one Main, Master form which holds all other forms in the aplication. For example, Master form has a toobar in which you can open more forms, all of which are 'inside' the master, and you cant drag them out of the main form - it contains them. Also, if you close the main form all forms close with it, but closing "lesser" forms do not affect the Master. I know this is a pretty clumsy explanation but I hope you unsderstand what I mean. I thank you upfront, for all your help!

You are talking about an MDI (Multiple Document Interface) application. Do a search on MdiChild and you should get enough hits to satisfy your question.

JerryShaw 46 Posting Pro in Training

dont cast those strings to char
especially if is not a char[] array... hint

just send the text of the components into the parameter assignment.

cmd.Parameters.AddWithValue("@customer", customercopyCB.Text);
JerryShaw 46 Posting Pro in Training

Why not just get the minimum date from the database instead of iterating through it in code.
use the Min() aggregate to pull it out.

JerryShaw 46 Posting Pro in Training

Yes, the for--loop is inside the thread method.

JerryShaw 46 Posting Pro in Training

I sugest you take a different tact.

What I typically do for managing thread messages is I create a simple EventArgs class to hold the message information, a Delegate to represent the main thread method that will use the information, and an eventhandler in the main thread that can be assigned to an event in the thread.

So to start, build a simple EventArgs class

public class ProgressEventArgs : EventArgs
    {
        private int _maxValue = 100;
        private int _value = 0;
        private string _text = string.Empty;

        public int MaxValue
        {
            get { return _maxValue; }
        }
        public int Value
        {
            get { return _value; }
        }
        public string Text
        {
            get { return _text; }
        }
        public ProgressEventArgs(string text, int value, int maxValue)
        {
            _text = text;
            _value = value;
            _maxValue = maxValue;
        }
        public override string ToString()
        {
            return _text;
        }
    }

Now create a public delegate. Typically I have a constants.cs file where I create all of my constants, and then outside of the constants class, but in the same name space, I create my delegates like this:

namespace MyNameSpace
{
    public delegate void ProgressEvent(object sender, ProgressEventArgs e);
    public class Constants
   {
   }
}

OR you can just add the delegate to the main form.

Next you want to create the method that will receive the event, and process the information (in the main form)

public void SetProgressEvent(object sender, ProgressEventArgs e)
        {
            if( label1.InvokeRequired )
            {
                ProgressEvent d = new …
JerryShaw 46 Posting Pro in Training

string relPath = System.IO.Path.Combine(Application.StartupPath,"YourFile.xml");

JerryShaw 46 Posting Pro in Training

string b = "mansi^^^^sharma";string b = "mansi^^^^sharma";
string[] splt = b.Split(new char[] { '^' ,'^','^','^'});

JerryShaw 46 Posting Pro in Training

Images have to be stored somewhere, a DB, files or resource.
I suggest only loading the images on demand for each question.
If using resources then just set the picturebox image property to the resource.

//PictureBox pictbox....
pictbox.Image = Properties.Resources.MyPicture;
JerryShaw 46 Posting Pro in Training

Are talking about the @quotenum as an Sql Parameter to the stored procedure ?
The stored procedure must declare this as an OUTPUT parameter.
Then you set your SqlParameter Direction so that it also knows it is an OUTPUT type and will store the value in the parameter.Value upon return.

Hope that helps

JerryShaw 46 Posting Pro in Training

I mean
chkActive.Checked=dt.Rows[0][whateverColumnThisIs];