如何使用Asp.net C#在转发器控件中动态下拉列表,测试框和按钮 [英] How to dropdownlist, testbox and button dynamically in repeater control using Asp.net C#

查看:97
本文介绍了如何使用Asp.net C#在转发器控件中动态下拉列表,测试框和按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我面临一个问题..



我想加一个溺水表它从数据库和两个文本框绑定,一个动态添加按钮到转发器控件。



但如果我单击添加按钮,那么下一行将在转发器上添加无法绑定以前行的下拉列表。所有下拉列表都在重置,但文本框值不会影响任何内容..





请任何人都可以帮助asp.net c#中的示例代码在按钮单击时将下拉列表选定值绑定到转发器。如果使用selectedvalue属性,则会出现错误。在设计方面我无法绑定下拉列表selectvales。







谢谢

S.Chand Basha

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

推荐答案

你必须通过使用以下代码在绑定转发器时找到控制,然后你可以从数据库获取数据并将这些控件绑定为wi在page_load事件中绑定为后端...



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...

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");
    }





祝你有美好的一天



Reguards,



Hardik Patel


Hi Hardik Patel,

感谢您的快速回复。我的要求是从最终用户获取数据,然后在提交按钮之后,数据必须一次插入数据库。



第一个用户点击添加按钮然后行必须生成和用户输入数据,如果他需要再添加一行点击添加按钮。像这样,用户可以根据需要添加任意数量的行。所以我想提供每行删除按钮,这样如果用户想要在进入数据库之前想要删除行,他就可以做到。



这里我的问题是下拉选择值没有绑定到转发器,以便我可以将数据插入数据库。请为我提供此问题的解决方案。
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.


这篇关于如何使用Asp.net C#在转发器控件中动态下拉列表,测试框和按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆