How do I bind a dataset to a #

I got this code template from https://www.wix.com/corvid/new-reference/wix-dataset/dynamicdataset/getcurrentitem

$w.onReady( () => {
  $w("#myDataset").onReady( () => {
 let itemObj = $w("#myDataset").getCurrentItem();
  } );
} );

Hi! I am trying to use the code above to retrieve data from my dataset but the program is giving me an error saying #myDataset is not valid.
What is supposed to go into the #?

I also heard that I’m supposed to bind/connect #myDataset to my database collection? How would I do that?

Thanks!

Hello Melia,

what you have is just a example-code.

$w.onReady( () => {
  $w("#myDataset").onReady( () => {
 let itemObj = $w("#myDataset").getCurrentItem();
  } );
} );

You have to modify it and set it right. Like you sad, you have to bind/connect it.
Look which ID has your Dataset. I assume it will be the ID —> “dataset1” if it is the first and only one on your page.
So if it is like i assume, then your code should be the following…

$w.onReady( () => {
  $w("#dataset1").onReady( () => {
 let itemObj = $w("#dataset1").getCurrentItem();
  } );
} );

Hi dima,

Thank you so much for replying.
I have tried #dataset1 but it is invalid.

How do I find which ID has my dataset?

Actually, I found the ID https://www.wix.com/corvid/forum/community-discussion/how-can-i-check-the-dataset-key-id

You are already close to make it. If it still do not work after your next try, i will try to make a example for you. Look into your other post.

Thank you so much dima! I have connected the ID key.
I really appreciate your help.

Now I am stuck connecting my variable to a Javascript Date()
https://www.wix.com/corvid/forum/community-discussion/connect-database-to-js-date