Hi tim,
I found that the Repeater.Controls.Add() function was a nice way to add
buttons to the repeater, that way I can set all the properties of the
button before is's added to the repeater.
Button btn = new Button();
btn.ID = i.ToString();
btn.Click += FyllingsKnapp_Click;
btn.Text = row[0].ToString();
btn.ToolTip = row[1].ToString();
repFylleknapper.Controls.Add(btn);
But I have one problem:
I have used context to transfere values between pages with
Server.Transfere(), but when I press one of the buttons in the Repeater,
there is a postback performed. And when I come to the clickeventhandler
for the buttons, all the previus values is gone exept for the button
values because its's reloaded during postback.
Any suggestions?
I have also posted the question in another thread.
Thanks Totto
Tim_Mac said:
hi totto,
that's what i would use. the repeater is the most light-weight, so it is
the fastest to use when you don't need all the grid functionality, and it
generates no HTML markup except what you specify. it should work if you
declare the OnClick event handler in the repeater itemtemplate for the
button. make sure your event handler is marked Public.
if your events aren't firing, post your code here and i'll take a look at
it. dynamic controls can be difficult to get your head around at first,
because of the postback life-cycle.
tim