Home All Groups Group Topic Archive Search About
Author
5 May 2005 7:45 PM
Tim Farrell via DotNetMonster.com
Firstly,

I am somewhat new to this so I am sure the fault is based on my
inexperience.

I have a repeater control in which I display record summaries from a
database.  Within the repeater control is a linkbutton control that I am
trying to use to allow users to view an entire record.

The code for the linkbutton control is as follows:
asp:LinkButton Runat="server" ID="details" OnClick="Click_Details">
  <%# DataBinder.Eval(Container.DataItem, "Cust_Name")%>
</asp:LinkButton>

The onClick event is supposed to call an event in the code behind which in
turns calls for the visibility of Panel2.

Here is the code for that:
public void Click_Details(object Sender, EventArgs e)
  {
    Panel1.Visible = false;
    Panel2.Visible = true;

    //object vars
    SqlConnection sqlConnection;
    SqlDataAdapter sqlDataAdapter;
    DataSet dataSet;

    try
    {
    sqlConnection = new SqlConnection ConfigurationSettings.AppSettings[
"dsn_SQL"]);
   //pass the SqlCommand
   SqlCommand command = new SqlCommand( "Details", sqlConnection );
   command.CommandType = CommandType.StoredProcedure;
   sqlConnection.Open();
   command.Parameters.Add("@id", SqlDbType.Int, 4);
   command.Parameters["@id"].Value = ID;
   command.ExecuteNonQuery();

   //instantiate SqlAdapter and DataSet
   sqlDataAdapter = new SqlDataAdapter (command);
   dataSet = new DataSet();

   //populate the dataset
   sqlDataAdapter.Fill( dataSet, "HSCTI" );

   //apply the sort to the DefaultView to sort the record by date
   postDetails.DataSource = dataSet.Tables["HSCTI"].DefaultView;
   postDetails.DataBind();
   sqlConnection.Close();
   }
   catch( Exception exception )
     {
     errorMsgLabel2.Text = exception.ToString();
     }
   }

The problem I am having is that I can't seem to capture the id value of the
item selected in the repeater control.  The error message I am getting is
the the value for @ID is not present.

I tested my SQL Stored Procedure and it works fine.

Thank you for your thoughts,

Sincerely,

Tim

Author
5 May 2005 8:36 PM
samuelrobertson
Why are you making ID an integer type?  Isn't it supposed to equal
"details"?

Also shoudn't you be setting @ID and not @id?
Author
6 May 2005 12:35 PM
Tim Farrell via DotNetMonster.com
Samuel,

Thanks for your time and thoughts. 

The reason the ID was given an INT integer type is because it is the
primary key for the table in which it resides (HSCTI).

The way the page is currently setup, I have three panels.  Panel 1 is made
up of a repeater control that gives the user a summary of data contained
within the HSCTI table for each customer.  There is a link button that
wraps around the Customer name and when clicked on calls a function that
populates and reveals Panel2 with the details of the record.  Inside Panel2
is a Comments button that(when clicked) reveals Panel3 which is a comments
field for users to make notes about the record or customer.  This form
contains a "Add Comment" button and when clicked calls a function to
populate the Comments table with the record and the ID from the original
customer record.

So in essence the application is accessing/querying two tables to get
results and post records.  HSCTI and Comments.  The ID of HSCTI is the
linking element between the two.

So my problem to date is that I can't seem to retain the value of the ID
fro HSCTI in order to filter records received from the comments table.

Any ideas?

Thanks for your help.

Tim

--
Message posted via http://www.dotnetmonster.com