按钮在Html表格中不可见
本文关键字:表格 Html 按钮 | 更新日期: 2023-09-27 18:05:33
我在Azure中维护Azure Mobile服务数据。我将需要访问的Azure移动服务数据进入网页。所以,我的数据添加在html正常表。它的工作。但我需要设置每一行编辑删除选项。我该怎么做呢?我尝试每一行添加按钮。但是按钮在表格中不可见
WebForm.aspx
<form id="form1" runat="server" >
<table id="DBDataPlaceHolder1" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th class="auto-style1">Code</th>
<th class="auto-style1">Name</th>
<th class="auto-style1">Descrption</th>
<th class="auto-style1">Sort</th>
<th class="auto-style1">Enable</th>
<th class="auto-style1">Action</th>
</tr>
</thead>
<asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder>
</table>
</form>
WebFormaspx.cs
protected void Page_Load(object sender, EventArgs e)
{
RetrieveAzureAsync(sender,e);
}
async private void RetrieveAzureAsync(object sender, EventArgs e)
{
StringBuilder htmlTable = new StringBuilder();
// This query filters out completed TodoItems and
// items without a timestamp.
IMobileServiceTable<BranchList> BranchTable = client.GetTable<BranchList>();
List<BranchList> items_list = await BranchTable
.Where(branchitem => branchitem.Enable == true)
.ToListAsync();
MyGridView1.DataSource = items_list;
MyGridView1.DataBind();
int size = items_list.Count();
if (size > 0)
{
for (int i = 0; i < size; i++)
{
htmlTable.Append("<tr>");
htmlTable.Append("<td>" + items_list[i].BranchCode + "</td>");
htmlTable.Append("<td>" + items_list[i].BranchName + "</td>");
htmlTable.Append("<td>" + items_list[i].Descr + "</td>");
htmlTable.Append("<td>" + items_list[i].Sort + "</td>");
htmlTable.Append("<td>" + items_list[i].Enable + "</td>");
htmlTable.Append("<td> <asp:Button ID='Button2' runat='server' Text='Button' OnClick='Button1_Click' /> </td>"); //this button not visble in table at run time
htmlTable.Append("</tr>");
}
htmlTable.Append("</table>");
PlaceHolder1.Controls.Add(new Literal { Text = htmlTable.ToString() });
}
}
<asp:Button ID='Button2' runat='server' Text='Button' OnClick='Button1_Click' />
替换为
<button id="btnSubmit" runat="server" class="myButton"
onserverclick="Button1_Click">Edit</button>