how can i retrive values from dataset in textbox in UI layer [Resolved]

Posted by Rickeybglr under ASP.NET on 7/11/2011 | Points: 10 | Views : 10031 | Status : [Member] | Replies : 4
public DataSet updateUser(string strSession)

{
sqlconnection.Open();


SqlCommand cmdUpdateUser = new SqlCommand("sp_updateUserProfile", sqlconnection);
cmdUpdateUser.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter("@uni_username", SqlDbType.NVarChar);
param.Value = strSession;
cmdUpdateUser.Parameters.Add(param);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = cmdUpdateUser;
DataSet dataset = new DataSet();
adapter.Fill(dataset);
cmdUpdateUser.Connection.Close();
return dataset;

i have written the following code in datalayer
how can i retrive values from dataset in textbox in UI layer





Responses

Posted by: Loganathanav on: 7/11/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,

The answer seems to be very simple for your problem.
Just use the statements like below, this will solve your problem.

DataSet ds = DAL.updateUser(strSession);
txtName.Text = ds.Tables[0].Rows[0]["Name"].ToString();

Hope this helps!

Rickeybglr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: RaviRanjanKr on: 7/11/2011 [Member] Starter | Points: 25

Up
0
Down
Try
DataTable dt = ds.Tables["TableName"];

textbox1.Text = dt.row[index][ColumnName/Index];


Thanks
Ravi Ranjan Kumar
http://raviranjankr.wordpress.com

Rickeybglr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Umeshdwivedi on: 7/12/2011 [Member] Starter | Points: 25

Up
0
Down
hallo try it
string strSession =Convert.ToString(Session["username"]);

DataSet ds = updateUser(strSession);

if(ds.Tables[0].Rows.Count>0)
{
foreach (DataRow row in ds.Tables[0].Rows)
{
TextBox1.Text =Convert.ToString(row["column_name1"]);
TextBox2.Text =Convert.ToString(row["column_name2"]);
...
}
}





Second try
In UI Layer:


Declared dataset and declare the object of dataaccess layer class;

dataset ds=new dataset();


ds= classObject.updateUser(strSession);

Textbox1.text=ds.tables[0].rows[rowindex]["columnindex"].ToString();

index parameter may be string or int.

you have third option
string ColValue = DataSet.Tables["NameOfTable"].Rows[RowIndex]["ColumnName"].ToString();

Index Parameter could be a int or string.


Latest Technology Trainer
And Part time software consultant

Rickeybglr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rickeybglr on: 7/12/2011 [Member] Starter | Points: 25

Up
0
Down
yup!!!
thnxs its working .....

Rickeybglr, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response