Filling data from SQL 2005 in ASP.NET

Hello,

I am working with my first ASP.NET project, and I have a question. I have successfully connected my asp.net project to my SQL2005 DB, and have bound all of the controls to their respective data, but what code do I need to make all of the controls fill with the appropriate data once the record is selected that is the primary key

Thanks!



Answer this question

Filling data from SQL 2005 in ASP.NET

  • Jasonval2005

    assuming you are using a table adapter, you need to fill the table adapter in the page load event with the relevant record (air code):

    string primaryKey = somevalue;

    this.TableAdapter.FillByID(this.DataSet.DataTable, primaryKey.ToString());

    Your table adapter query (named FillByID for this example) should use a parameter like:

    select * from table where primaryKeyID=@primaryKeyID


  • Filling data from SQL 2005 in ASP.NET