TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
kapil dev
NA
8
1.5k
Please tell me whole functionality for Editing repeater.................Thanks
Oct 18 2012 4:33 AM
private void BindRepeater()
{
SqlConnection SqlCnn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand SqlCmd = new SqlCommand("select * from SchoolGenDetails", SqlCnn);
SqlDataAdapter SqlAd1 = new SqlDataAdapter(SqlCmd);
DataSet ds = new DataSet();
SqlAd1.Fill(ds);
cpRepeater.DataSource = ds;
cpRepeater.DataBind();
}
//The code in ItemDataBound event of repeater.
//Populating the dropdownlist dynamically.
protected void cpRepeater_ItemCommand1(object source, RepeaterCommandEventArgs e)
{
//DropDownList ddlType = (DropDownList)e.Item.FindControl("ddlType");
//if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
//{
// SqlConnection SqlCnn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
// SqlCommand SqlCmd = new SqlCommand("select * from Country", SqlCnn);
// SqlDataAdapter SqlAd1 = new SqlDataAdapter(SqlCmd);
// DataSet ds = new DataSet();
// DataTable dt = new DataTable();
// SqlAd1.Fill(dt);
// ddlType.DataTextField = "CountryName";
// ddlType.DataValueField = "CountryID";
// ddlType.DataSource = dt;
// ddlType.DataBind();
//}
TextBox txtname = (TextBox)e.Item.FindControl("txtName");
txtname.Visible = true;
Label lblName = (Label)e.Item.FindControl("lblName");
lblName.Visible = false;
LinkButton lnkUpdate = (LinkButton)e.Item.FindControl("lnkUpdate");
lnkUpdate.Visible = true;
LinkButton lnkCancel = (LinkButton)e.Item.FindControl("lnkCancel");
lnkCancel.Visible = true;
LinkButton lnkEdit = (LinkButton)e.Item.FindControl("lnkEdit");
lnkEdit.Visible = false;
if (e.CommandName == "update")
{ }
else if (e.CommandName == "cancel")
{
BindRepeater();
}
}
protected void cpRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
DropDownList ddlType = (DropDownList)e.Item.FindControl("ddlType");
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
SqlConnection SqlCnn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand SqlCmd = new SqlCommand("select * from Country", SqlCnn);
SqlDataAdapter SqlAd1 = new SqlDataAdapter(SqlCmd);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
SqlAd1.Fill(dt);
ddlType.DataTextField = "CountryName";
ddlType.DataValueField = "CountryID";
ddlType.DataSource = dt;
ddlType.DataBind();
}
////TextBox txtname = (TextBox)e.Item.FindControl("txtName");
////txtname.Visible = true;
////Label lblName = (Label)e.Item.FindControl("lblName");
////lblName.Visible = false;
}
this is my code......
I m hiding the Link button on item command is this right appproach...........
Attachment:
repeaterediting.rar
Reply
Answers (
1
)
Updating Only Changed Rows Using GridView Control
Insert Record From GridView to Sql in Asp.Net