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
kshama parashar
NA
89
0
runtime event handler of dynamic generated linkbutton
Jun 14 2010 9:14 AM
i want to generate click event at runtime of dynamically generated linkbutton my code is:
protected void btnecat_Click(object sender, EventArgs e)
{
OleDbCommand cmd = con.CreateCommand();
cmd.CommandText = "select subcategory1 from subcategory where cateid='1'";
OleDbDataReader dr = cmd.ExecuteReader();
int count = 1;
while (dr.Read())
{
lin = new LinkButton();
//lin.ID = linkbtncat + count.ToString();
lin.ID="lin_"+count.ToString();
lin.Text = dr.GetString(0);
lin.CommandName = "lin" + count.ToString();
lin.CommandArgument = count.ToString();
lin.Click += new EventHandler(lin_Click);
Panel2.Controls.Add(lin);
Panel2.Controls.Add(new LiteralControl("<br>"));
count = count + 1;
}
}
void lin_Click(object sender, EventArgs e)
{
string str1 = ((LinkButton)sender).CommandArgument;
switch (str1)
{
case "1":
tx = lin.Text;
Panel3.Visible = true;
OleDbCommand cm = con.CreateCommand();
cm.CommandText = "select * from itemsale where itemsubcat='tv'";
OleDbDataReader d = cm.ExecuteReader();
while (d.Read())
{
lblitemcode.Text = d.GetString(0);
lblitemname.Text = d.GetString(1);
lblitemcat.Text = d.GetString(2);
lblitemsu.Text = d.GetString(3);
lblcomp.Text = d.GetString(4);
lblrate.Text = d.GetString(5);
}
break;
}
}
Reply
Answers (
5
)
Parametized Query--Filtering a Datagrid with combo box
GetAttributes on DFS