C
cpn008
I have a dynamically created gridview with a templatefield column. It
contains one button. The code is below. Basically what happens is that
the InstantiateIn() method fires EVERY time, the button_DataBinding()
method is never fired on Postback (it fires fine on initial page
load). As a result, I am unable to get the dataValue and do the
necessary binding on Postback. This is Bad Juju!
Any direction you can point me in would be greatly appreciated.
Thanks!
1 public void InstantiateIn( Control container )
2 {
3 ..
4
5 Button button = new Button();
6 button.Text = "Edit";
7
8 button.DataBinding += new EventHandler
( button_DataBinding );
9
10 container.Controls.Add(button);
11 }
12
13
14 private void button_DataBinding( object sender, EventArgs e )
15 {
16 Button button = (Button)sender;
17 GridViewRow row = (GridViewRow)button.NamingContainer;
18
19 object dataValue = DataBinder.Eval(row.DataItem, "ID");
20 ..
21 }
22
contains one button. The code is below. Basically what happens is that
the InstantiateIn() method fires EVERY time, the button_DataBinding()
method is never fired on Postback (it fires fine on initial page
load). As a result, I am unable to get the dataValue and do the
necessary binding on Postback. This is Bad Juju!
Any direction you can point me in would be greatly appreciated.
Thanks!
1 public void InstantiateIn( Control container )
2 {
3 ..
4
5 Button button = new Button();
6 button.Text = "Edit";
7
8 button.DataBinding += new EventHandler
( button_DataBinding );
9
10 container.Controls.Add(button);
11 }
12
13
14 private void button_DataBinding( object sender, EventArgs e )
15 {
16 Button button = (Button)sender;
17 GridViewRow row = (GridViewRow)button.NamingContainer;
18
19 object dataValue = DataBinder.Eval(row.DataItem, "ID");
20 ..
21 }
22