Hello
I'm filling a data set in C# from an SQL database and then binding
this to a repeater. I have an OnItemCreated method on this repeater
and I am trying to get the value in a column called "ServiceFK".
However, it appears I can only use an index rather than a column name
which I am loathe to do. Can anyone help? Here's a sample of my code:
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection connection = new
SqlConnection(ConfigurationManager.ConnectionStrin gs["Connection"].ToString());
SqlCommand command = connection.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "sp_GetAllServices";
connection.Open();
SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet, "Service");
ServicesRepeater.DataSource = dataSet.Tables["Service"];
ServicesRepeater.DataBind();
connection.Close();
}
protected void ServicesRepeater_OnItemCreated(object Sender,
RepeaterItemEventArgs e)
{
SqlConnection connection = new
SqlConnection(ConfigurationManager.ConnectionStrin gs["wealdConnection"].ToString());
SqlCommand command = connection.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "sp_GetFeatures";
command.Parameters.AddWithValue("@serviceID",
DataBinder.Eval(e.Item.DataItem, "serviceID")); // fails here with
serviceID
....
....
....
....
}
Any help greatly appreciated!
Thanks, Mark 2 1343
Actually, it doesn't even work with an index! How do I get the value
at all??
On Jul 3, 1:45*pm, mark.norg...@gmail.com wrote:
Hello
I'm filling a data set in C# from an SQL database and then binding
this to a repeater. I have an OnItemCreated method on this repeater
and I am trying to get the value in a column called "ServiceFK".
However, it appears I can only use an index rather than a column name
which I am loathe to do. Can anyone help? Here's a sample of my code:
* * protected void Page_Load(object sender, EventArgs e)
* * {
* * * * SqlConnection connection = new
SqlConnection(ConfigurationManager.ConnectionStrin gs["Connection"].ToString*());
* * * * SqlCommand command = connection.CreateCommand();
* * * * command.CommandType = CommandType.StoredProcedure;
* * * * command.CommandText = "sp_GetAllServices";
* * * * connection.Open();
* * * * SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
* * * * DataSet dataSet = new DataSet();
* * * * dataAdapter.Fill(dataSet, "Service");
* * * * ServicesRepeater.DataSource = dataSet.Tables["Service"];
* * * * ServicesRepeater.DataBind();
* * * * connection.Close();
* * }
* * protected void ServicesRepeater_OnItemCreated(object Sender,
RepeaterItemEventArgs e)
* * {
* * * * SqlConnection connection = new
SqlConnection(ConfigurationManager.ConnectionStrin gs["wealdConnection"].ToS*tring());
* * * * SqlCommand command = connection.CreateCommand();
* * * * command.CommandType = CommandType.StoredProcedure;
* * * * command.CommandText = "sp_GetFeatures";
* * * * command.Parameters.AddWithValue("@serviceID",
DataBinder.Eval(e.Item.DataItem, "serviceID")); // fails here with
serviceID
...
...
...
...
}
Any help greatly appreciated!
Thanks, Mark
On Jul 3, 2:17*pm, mark.norg...@gmail.com wrote:
Actually, it doesn't even work with an index! How do I get the value
at all??
On Jul 3, 1:45*pm, mark.norg...@gmail.com wrote:
Hello
I'm filling a data set in C# from an SQL database and then binding
this to a repeater. I have an OnItemCreated method on this repeater
and I am trying to get the value in a column called "ServiceFK".
However, it appears I can only use an index rather than a column name
which I am loathe to do. Can anyone help? Here's a sample of my code:
* * protected void Page_Load(object sender, EventArgs e)
* * {
* * * * SqlConnection connection = new
SqlConnection(ConfigurationManager.ConnectionStrin gs["Connection"].ToString**());
* * * * SqlCommand command = connection.CreateCommand();
* * * * command.CommandType = CommandType.StoredProcedure;
* * * * command.CommandText = "sp_GetAllServices";
* * * * connection.Open();
* * * * SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
* * * * DataSet dataSet = new DataSet();
* * * * dataAdapter.Fill(dataSet, "Service");
* * * * ServicesRepeater.DataSource = dataSet.Tables["Service"];
* * * * ServicesRepeater.DataBind();
* * * * connection.Close();
* * }
* * protected void ServicesRepeater_OnItemCreated(object Sender,
RepeaterItemEventArgs e)
* * {
* * * * SqlConnection connection = new
SqlConnection(ConfigurationManager.ConnectionStrin gs["wealdConnection"]..ToS**tring());
* * * * SqlCommand command = connection.CreateCommand();
* * * * command.CommandType = CommandType.StoredProcedure;
* * * * command.CommandText = "sp_GetFeatures";
* * * * command.Parameters.AddWithValue("@serviceID",
DataBinder.Eval(e.Item.DataItem, "serviceID")); // fails here with
serviceID
...
...
...
...
}
Any help greatly appreciated!
Thanks, Mark- Hide quoted text -
- Show quoted text -
Doh! Was being an idiot. I simply need:
command.Parameters.AddWithValue("@serviceID",
((DataRowView)e.Item.DataItem)["ServiceID"]); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joe Gazda |
last post by:
I'm a relative newbie to PHP, but have been able to put together some PHP
code to generate a CSV/XLS file from a Query result. Now, I would like to
include custom column names instead of the MySQL...
|
by: noor |
last post by:
Hi
I have been working since 2 days to device a method to export sql table
into csv format. I have tried using bcp with format option to keep the
column names but I'm unable to transfer the file...
|
by: TTroy |
last post by:
Hello, I'm relatively new to C and have gone through more than 4 books
on it. None mentioned anything about integral promotion, arithmetic
conversion, value preserving and unsigned preserving. ...
|
by: Larry Bird |
last post by:
I've created a AlertDataClass below within the class I have tables and column that I've create. In the AlertDataAccess class I'm trying to insert data into my tables. AlertDataAccess is a Module...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |