How to dynamically bind asp.net repeater control to datasource

前端 未结 5 665
情话喂你
情话喂你 2021-01-21 06:22

I have a page with a simple dropdown and repeater control in page.on submit repeater control is bound to datasource1 which has 3 columns.

5条回答
  •  难免孤独
    2021-01-21 07:04

    Try settings AutoPostback=true on your dropdownlist. Then, have a "selectedindexchanged" event handler on your codebehind setup to read the value and set the datasource accordingly, something similar to:

    repeater1.DataSource=
    repeater1.DataBind()
    

    If your datasource is always using the same columns for your presentation, then this shouldn't be an issue. If your datasources will vary in the columns of data that they return, then Kashif's comment in your question may help you some. Otherwise, you just need to fill in the logic above to set the Datasource property of your repeater to whatever your datasource is...

    Hope this helps

提交回复
热议问题