Click here to Skip to main content
15,912,205 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
Hi Friends,

Am Facing one issue..

I want to add one drownlist which binds from database and two textboxes and one add button dynamically to repeater control.

But if I click Add button so that next row will added on repeater at that time am not able to bind dropdownlist of previous rows. All dropdownlists are reseting but textbox values are not effecting anything..


Please can anyone help with sample code in asp.net c# to bind the dropdownlist selected value to the repeater on button click. If am using "selectedvalue" property then getting error. In Design side am not able to bind the dropdownlist selectedvales.



Thanks
S.Chand Basha
Posted

You have to find control while Binding repeater by using following code and then you can get data from database and bind those controls as wi binding as back end side in page_load event...

C#
public void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        TextBox lbl = (TextBox)e.Item.FindControl("TextBox1");
        DropDownList lblFollower = (DropDownList)e.Item.FindControl("DropDownList1");
        Button btnFollow = (Button)e.Item.FindControl("Button1");
    }


Have a nice Day

Reguards,

Hardik Patel
 
Share this answer
 
v2
Comments
chand5055 14-May-14 3:23am    
Hi Hardik Patel,
Thanks for quick response. My requirement is taking data from the end user and after the submit button then data must inserted at a time in Database.

First user click Add button then row must generate and user enter data if he needs add one more row click on add button. Like this user can add as many rows as he required. SO I want to provide each row delete button also so that if user wants before entering into database wants to delete the row he can do it.

Here my problem is dropdown selected value is not binding to repeater so that I can insert data into database. Please provide me solution for this issue.
HardikPatel.SE 14-May-14 3:40am    
Ohk.... For that I think you have to reload page on button click and if the other way is there, than I am not aware of it....
And yes you can also use a grid view for that functionality.... & you can also bind using javascript.... & you can attach new div or table-tr to display controls.... I'll give you example when I'll create it...
Hi Hardik Patel,
Thanks for quick response. My requirement is taking data from the end user and after the submit button then data must inserted at a time in Database.

First user click Add button then row must generate and user enter data if he needs add one more row click on add button. Like this user can add as many rows as he required. SO I want to provide each row delete button also so that if user wants before entering into database wants to delete the row he can do it.

Here my problem is dropdown selected value is not binding to repeater so that I can insert data into database. Please provide me solution for this issue.
 
Share this answer
 
Comments
Member 9158651 24-Oct-18 22:58pm    
Can any one provide the answer for chand5055 question I am kind of struck with that issue

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900