corbpm
asked on
ObjectDataSource field accessing using C#
Using Visual Web Developer 2005 Express and concentrating on C#
My C# knowledge is limited but want to do this in C# if possible, if its not it would at least let me sleep tonight.
I have added a ObjectDataSource and pointed a Formview component to it successfully (and it works !!!)
In the C# Page_Load i want to access a field in the ObjectDataSource and have not the foggiest idea how to do it, i don't just want to DataBind the field i want to get it into a String so i can beat up the value, whisk it slightly then eventually stuff it out again.
I have been able to create a new SqlConnection and get the field that way its just that i'm annoyed that i can't figure out how to get the field that is already available on the ASP component !
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string WhatsTheValue = ObjectDataSource1["GIVEMET HESTUPIDVA LUE"];
}
}
My C# knowledge is limited but want to do this in C# if possible, if its not it would at least let me sleep tonight.
I have added a ObjectDataSource and pointed a Formview component to it successfully (and it works !!!)
In the C# Page_Load i want to access a field in the ObjectDataSource and have not the foggiest idea how to do it, i don't just want to DataBind the field i want to get it into a String so i can beat up the value, whisk it slightly then eventually stuff it out again.
I have been able to create a new SqlConnection and get the field that way its just that i'm annoyed that i can't figure out how to get the field that is already available on the ASP component !
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string WhatsTheValue = ObjectDataSource1["GIVEMET
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If that doesn't suit your needs, get the data via a connection, command, data adapter, and DataSet. Then, get your value(s) to manipulate accordingly from the DataSet. Finally, manually bind the data to the FormView.
FormView1.DataSource = Data.Tables[0]; // Data is the DataSet filled.
FormView1.DataBind();
FormView1.DataSource = Data.Tables[0]; // Data is the DataSet filled.
FormView1.DataBind();
ASKER
Thanks that works !!!!
but from datasouce you can get and set QueryText .. like
ObjectDataSource1.SelectCo
for value you must look into the control which you have bound with datasource?
thanks