Wednesday, March 7, 2012

dynamically binding button and controls on table rows.

Hi,

I am new to .NET world. I am using visual studio express.

I am developing website using ASP.NET and C#.

I want to add buttons dynamically on a table row on my web page.

For this I have written this code in "example.aspx" file

<asp:TableID="tblExample"GridLines="Both"BorderWidth="1"runat="server">

</asp:Table>

In my corresponding "example.aspx.cs" file i have written

TableRow tr = new TableRow();

.....................

.....................

TableCell tc3 = new TableCell();

tc3.Width = 120;

Button bt = new Button();

bt.Text = btnStop.Text;

bt.Width = 120;

bt.CommandArgument = lrs.IpAddress + ":" + lrs.PortNo;

bt.Click += newEventHandler(cmdStop_Click);

tc3.Controls.Add(bt);

tr.Cells.Add(tc3);

tblExample.Rows.Add(tr);

In my EventHandler "cmdStop_Click" I am trying to perform some action but on that particular row's data.

My page is also reloading after every 5 secs.

After clicking a button in a row, when page refreshes, I am getting this message in popup error message. also that entry is ommited(as per code in EventHandler)

"The Page cannot be refreshed without resending the information.

Click retry to resend the information again.

or click Cancel to return to the page that you were trying to view"

resetButton cancelButton

_

How to bind that button to particular row so that when I click on a button the action should be performed on that particular row's data.

Thanks

Smile

I think that if you visit this site, you will find quite a few very good instructional videos that will help you create your website.

http://asp.net/learn/videos/default.aspx?tabid=63

Your question is not really a SQL Server question, but more one of how to get started and learn ASP programming. Check out the site above.

No comments:

Post a Comment