Please Help - Access Current Row in table adapter

  • Thread starter Thread starter Troy Bull
  • Start date Start date
T

Troy Bull

Greetings

I am new to C# coming from Java / EJB. I have been messing around and
in an app i am working on I am trying to get access to the fields of the
current row in a table adapeter (current row from binding source).

Here it the code I found that works, is there a better way??

code --------------
private void button3_Click(object sender, EventArgs e)
{

System.Diagnostics.Debug.Write("-------------------------------------\n");
int rowNum = timelogBindingSource.Position;
TimeCard.HomeDataSet.timelogRow t =

(TimeCard.HomeDataSet.timelogRow)timelogTableAdapter.GetData().Rows[rowNum];
System.Diagnostics.Debug.WriteLine(t.timein);

System.Diagnostics.Debug.Write("-------------------------------------\n");
}
------------------
 
Finding a particular Row

try
{
int intRow;

// Finds the row specified in txtFindArg
intRow =
ds.Tables[0].DefaultView.Find(txtFindArg.Text);
Debug.WriteLine(intRow);
if (intRow == -1)
{
MessageBox.Show("No PK matches " +
txtFindArg.Text);
}
else
{
// Jump to the Row and select it
DataGrid.CurrentRowIndex = intRow;
DataGrid.Select(intRow);
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}


and



try
{
DataRow drFound;

// Find the Row specified in txtFindArg
drFound = ds.Tables[0].Rows.Find(txtFindArg.Text);
if (drFound == null)
{
MessageBox.Show("No PK matches " +
txtFindArg.Text);
}
else
{
txtFoundRow.Text = drFound[0].ToString() + ", " +
drFound[1].ToString() + ", " +
drFound[2].ToString();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
Debug.WriteLine(ex.ToString());
}


Regards

http://www.auratius.co.za

auratius
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top