Programatically using Datasets

  • Thread starter Thread starter Brian Conway
  • Start date Start date
B

Brian Conway

I am trying to dynamically generate a dataset that pulls back information
based off of a login id, once it has the dataset I want to take information
from the dataset and populate editable fields on a form. So far I know that
the click event works based off of the login id, because I can get a
datagrid to populate with the correct information. However, I don't want to
use a datagrid, I want to be able to use the dataset and bind the data from
the dataset columns which will only return one record to particular textbox
fields on the form. How do I do this. This is for a Webform.

I have tried this, but it kicks back several errors. (sn for some reason is
what they called lastname)
txtLastName.DataBindings.Add(new DataBinding("Text", CUID, "SN"));
 
You have to do it manually. If you sure that you will receive only one
record you can do this

TextBox1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_TextBox1"];
Label1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_Label1"];

if you can receive more than one record use Rows[index_of_the_row]

Regards
Martin Marinov
 
Thanks for the response.

I put that in there however, I am getting an error message from it. Can this
not go in the click event? The error I am getting is Cannot implicity
convert type object to string. I have included the whole section of code
that I have for my click event. I am using the datagrid right now for
testing to be sure I am getting a single record return which I do.

private void btnAutoFill_Click(object sender, System.EventArgs e)

{

{

Conference_Request.LDAP.AuthenticationServices User = new
Conference_Request.LDAP.AuthenticationServices();

DataSet CUID = new DataSet();

CUID = User.getUserInfo(txtCUID.Text);

DataGrid1.DataSource = CUID.Tables[0];

DataGrid1.DataBind();


txtLastName.Text = CUID.Tables[0].Rows[0]["sn"];

}

}

Martin Marinov said:
You have to do it manually. If you sure that you will receive only one
record you can do this

TextBox1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_TextBox1"];
Label1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_Label1"];

if you can receive more than one record use Rows[index_of_the_row]

Regards
Martin Marinov

Brian Conway said:
I am trying to dynamically generate a dataset that pulls back information
based off of a login id, once it has the dataset I want to take information
from the dataset and populate editable fields on a form. So far I know that
the click event works based off of the login id, because I can get a
datagrid to populate with the correct information. However, I don't
want
to
use a datagrid, I want to be able to use the dataset and bind the data from
the dataset columns which will only return one record to particular textbox
fields on the form. How do I do this. This is for a Webform.

I have tried this, but it kicks back several errors. (sn for some
reason
is
what they called lastname)
txtLastName.DataBindings.Add(new DataBinding("Text", CUID, "SN"));
 
it is not a problem with the event,
you have to implicity cast, e.g. :

txtLastName.Text = (string)CUID.Tables[0].Rows[0]["sn"];

Martin

Brian Conway said:
Thanks for the response.

I put that in there however, I am getting an error message from it. Can this
not go in the click event? The error I am getting is Cannot implicity
convert type object to string. I have included the whole section of code
that I have for my click event. I am using the datagrid right now for
testing to be sure I am getting a single record return which I do.

private void btnAutoFill_Click(object sender, System.EventArgs e)

{

{

Conference_Request.LDAP.AuthenticationServices User = new
Conference_Request.LDAP.AuthenticationServices();

DataSet CUID = new DataSet();

CUID = User.getUserInfo(txtCUID.Text);

DataGrid1.DataSource = CUID.Tables[0];

DataGrid1.DataBind();


txtLastName.Text = CUID.Tables[0].Rows[0]["sn"];

}

}

Martin Marinov said:
You have to do it manually. If you sure that you will receive only one
record you can do this

TextBox1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_TextBox1"];
Label1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_Label1"];

if you can receive more than one record use Rows[index_of_the_row]

Regards
Martin Marinov

Brian Conway said:
I am trying to dynamically generate a dataset that pulls back information
based off of a login id, once it has the dataset I want to take information
from the dataset and populate editable fields on a form. So far I
know
that
the click event works based off of the login id, because I can get a
datagrid to populate with the correct information. However, I don't
want
to
use a datagrid, I want to be able to use the dataset and bind the data from
the dataset columns which will only return one record to particular textbox
fields on the form. How do I do this. This is for a Webform.

I have tried this, but it kicks back several errors. (sn for some
reason
is
what they called lastname)
txtLastName.DataBindings.Add(new DataBinding("Text", CUID, "SN"));
 
Awesome, that worked, I have tried I don't know how many variations of
string but was using ToString. To much to learn.


Martin Marinov said:
it is not a problem with the event,
you have to implicity cast, e.g. :

txtLastName.Text = (string)CUID.Tables[0].Rows[0]["sn"];

Martin

Brian Conway said:
Thanks for the response.

I put that in there however, I am getting an error message from it. Can this
not go in the click event? The error I am getting is Cannot implicity
convert type object to string. I have included the whole section of code
that I have for my click event. I am using the datagrid right now for
testing to be sure I am getting a single record return which I do.

private void btnAutoFill_Click(object sender, System.EventArgs e)

{

{

Conference_Request.LDAP.AuthenticationServices User = new
Conference_Request.LDAP.AuthenticationServices();

DataSet CUID = new DataSet();

CUID = User.getUserInfo(txtCUID.Text);

DataGrid1.DataSource = CUID.Tables[0];

DataGrid1.DataBind();


txtLastName.Text = CUID.Tables[0].Rows[0]["sn"];

}

}

Martin Marinov said:
You have to do it manually. If you sure that you will receive only one
record you can do this

TextBox1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_TextBox1"];
Label1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_Label1"];

if you can receive more than one record use Rows[index_of_the_row]

Regards
Martin Marinov

I am trying to dynamically generate a dataset that pulls back information
based off of a login id, once it has the dataset I want to take
information
from the dataset and populate editable fields on a form. So far I know
that
the click event works based off of the login id, because I can get a
datagrid to populate with the correct information. However, I don't want
to
use a datagrid, I want to be able to use the dataset and bind the data
from
the dataset columns which will only return one record to particular
textbox
fields on the form. How do I do this. This is for a Webform.

I have tried this, but it kicks back several errors. (sn for some reason
is
what they called lastname)
txtLastName.DataBindings.Add(new DataBinding("Text", CUID, "SN"));
 
Is there a way to convert that to UpperCase?


Martin Marinov said:
it is not a problem with the event,
you have to implicity cast, e.g. :

txtLastName.Text = (string)CUID.Tables[0].Rows[0]["sn"];

Martin

Brian Conway said:
Thanks for the response.

I put that in there however, I am getting an error message from it. Can this
not go in the click event? The error I am getting is Cannot implicity
convert type object to string. I have included the whole section of code
that I have for my click event. I am using the datagrid right now for
testing to be sure I am getting a single record return which I do.

private void btnAutoFill_Click(object sender, System.EventArgs e)

{

{

Conference_Request.LDAP.AuthenticationServices User = new
Conference_Request.LDAP.AuthenticationServices();

DataSet CUID = new DataSet();

CUID = User.getUserInfo(txtCUID.Text);

DataGrid1.DataSource = CUID.Tables[0];

DataGrid1.DataBind();


txtLastName.Text = CUID.Tables[0].Rows[0]["sn"];

}

}

Martin Marinov said:
You have to do it manually. If you sure that you will receive only one
record you can do this

TextBox1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_TextBox1"];
Label1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_Label1"];

if you can receive more than one record use Rows[index_of_the_row]

Regards
Martin Marinov

I am trying to dynamically generate a dataset that pulls back information
based off of a login id, once it has the dataset I want to take
information
from the dataset and populate editable fields on a form. So far I know
that
the click event works based off of the login id, because I can get a
datagrid to populate with the correct information. However, I don't want
to
use a datagrid, I want to be able to use the dataset and bind the data
from
the dataset columns which will only return one record to particular
textbox
fields on the form. How do I do this. This is for a Webform.

I have tried this, but it kicks back several errors. (sn for some reason
is
what they called lastname)
txtLastName.DataBindings.Add(new DataBinding("Text", CUID, "SN"));
 
Yes,

txtLastName.Text = (string)CUID.Tables[0].Rows[0]["sn"];
txtLastName.Text = txtLastName.Text.ToUpper();

Regards
Martin

Brian Conway said:
Is there a way to convert that to UpperCase?


Martin Marinov said:
it is not a problem with the event,
you have to implicity cast, e.g. :

txtLastName.Text = (string)CUID.Tables[0].Rows[0]["sn"];

Martin

Brian Conway said:
Thanks for the response.

I put that in there however, I am getting an error message from it.
Can
this
not go in the click event? The error I am getting is Cannot implicity
convert type object to string. I have included the whole section of code
that I have for my click event. I am using the datagrid right now for
testing to be sure I am getting a single record return which I do.

private void btnAutoFill_Click(object sender, System.EventArgs e)

{

{

Conference_Request.LDAP.AuthenticationServices User = new
Conference_Request.LDAP.AuthenticationServices();

DataSet CUID = new DataSet();

CUID = User.getUserInfo(txtCUID.Text);

DataGrid1.DataSource = CUID.Tables[0];

DataGrid1.DataBind();


txtLastName.Text = CUID.Tables[0].Rows[0]["sn"];

}

}

You have to do it manually. If you sure that you will receive only one
record you can do this

TextBox1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_TextBox1"];
Label1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_Label1"];

if you can receive more than one record use Rows[index_of_the_row]

Regards
Martin Marinov

I am trying to dynamically generate a dataset that pulls back
information
based off of a login id, once it has the dataset I want to take
information
from the dataset and populate editable fields on a form. So far I know
that
the click event works based off of the login id, because I can get a
datagrid to populate with the correct information. However, I don't
want
to
use a datagrid, I want to be able to use the dataset and bind the data
from
the dataset columns which will only return one record to particular
textbox
fields on the form. How do I do this. This is for a Webform.

I have tried this, but it kicks back several errors. (sn for some
reason
is
what they called lastname)
txtLastName.DataBindings.Add(new DataBinding("Text", CUID, "SN"));
 
Thanks again, was going to do that but thought there might be a way to do it
all in one shot.


Martin Marinov said:
Yes,

txtLastName.Text = (string)CUID.Tables[0].Rows[0]["sn"];
txtLastName.Text = txtLastName.Text.ToUpper();

Regards
Martin

Brian Conway said:
Is there a way to convert that to UpperCase?


Martin Marinov said:
it is not a problem with the event,
you have to implicity cast, e.g. :

txtLastName.Text = (string)CUID.Tables[0].Rows[0]["sn"];

Martin

Thanks for the response.

I put that in there however, I am getting an error message from it. Can
this
not go in the click event? The error I am getting is Cannot implicity
convert type object to string. I have included the whole section of code
that I have for my click event. I am using the datagrid right now for
testing to be sure I am getting a single record return which I do.

private void btnAutoFill_Click(object sender, System.EventArgs e)

{

{

Conference_Request.LDAP.AuthenticationServices User = new
Conference_Request.LDAP.AuthenticationServices();

DataSet CUID = new DataSet();

CUID = User.getUserInfo(txtCUID.Text);

DataGrid1.DataSource = CUID.Tables[0];

DataGrid1.DataBind();


txtLastName.Text = CUID.Tables[0].Rows[0]["sn"];

}

}

You have to do it manually. If you sure that you will receive only one
record you can do this

TextBox1.Text =
dataSet.Tables[0].Rows[0]["The_column_name_for_TextBox1"];
Label1.Text = dataSet.Tables[0].Rows[0]["The_column_name_for_Label1"];

if you can receive more than one record use Rows[index_of_the_row]

Regards
Martin Marinov

I am trying to dynamically generate a dataset that pulls back
information
based off of a login id, once it has the dataset I want to take
information
from the dataset and populate editable fields on a form. So far I
know
that
the click event works based off of the login id, because I can
get
a the
data
 

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