小编Sup*_*tar的帖子

asp.net gridview复选框选择

需要一些帮助来解决这个问题.

我有一个gridview,在gridview中我有一个复选框,单击复选框后,我正在做一个回发事件,并尝试仅在数据库上更新此特定行.

这是我的gridview复选框代码.看到OnCheckedChanged.

<asp:TemplateField HeaderText="Sample">
  <ItemTemplate>
     <asp:CheckBox runat="server" 
                   ID="chkSample" 
                   Checked='<%# Bind("Sample") %>' 
                   OnCheckedChanged="UpdateSupplyLed" 
                   AutoPostBack="True">
    </asp:CheckBox> 
  </ItemTemplate>
</asp:TemplateField>
Run Code Online (Sandbox Code Playgroud)

码:

protected void UpdateSupplyLed(object sender, EventArgs e)
{
    foreach (GridViewRow di in SamplingGridView.Rows)    
    {        
        CheckBox chkBx = (CheckBox)di.FindControl("chkSample");
        if (chkBx != null && chkBx.Checked)
        {
            //update database logic here.
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

上面的代码工作正常,但它给我的所有复选框都被检查,而不管我刚检查的那个.我不想要他们所有人.

如何才能获得刚刚检查过的唯一一行值.某些行可能已经被检查过,因为这些记录的状态为true,我不想更新这些记录.

我想我的问题是对的!

更新:答案是:

protected void UpdateSupplyLed(object sender, EventArgs e)
{
    CheckBox chkSampleStatus = sender as CheckBox;        
    bool sample = chkSampleStatus.Checked;            
    GridViewRow row = chkSampleStatus.NamingContainer as GridViewRow;        
    TextBox txtId = row.FindControl("Id") …
Run Code Online (Sandbox Code Playgroud)

.net asp.net checkbox gridview

7
推荐指数
1
解决办法
3万
查看次数

关于.NET线程的访谈问题

您能描述两种同步对类成员执行的多线程写访问的方法吗?

请任何人帮助我这是什么意思,什么是正确的答案.

multithreading

7
推荐指数
2
解决办法
1万
查看次数

角度偏

目前我正在尝试将现有的Knockout应用程序迁移到Angular MEAN堆栈应用程序.在淘汰赛中,index.html包含此代码

<% layout('layout') -%>

<div data-bind="ifnot: id">
    <%- partial('partials/invitation-creating.html') %>
</div>

<div data-bind="if: id">
    <%- partial('partials/invitation-done.html') %>
</div>
Run Code Online (Sandbox Code Playgroud)

如何使用单个控制器(或)多个控制器实现这种带有Angular路径的部分html文件加载.保存'invitation-creating.html'页面后,我应该可以转到'invitation-done.html',但网址应该相同(我不想要这个 - > websiteurl/invitation_id)

请参阅http://invitify.azurewebsites.net中的操作,当您创建邀请时,它将带您到下一页(invitation-done.html),而无需浏览器更改它的URL.这是在淘汰赛中实现的,但我也希望在我的Angular应用程序中实现相同的效果.Knockout代码在github上,供您查看.https://github.com/scriptstar/KOInvitify

在Angular应用程序中实现此类行为的最佳实践是什么.

请帮忙.谢谢.

angularjs angular-ui-router angularjs-ng-route

0
推荐指数
1
解决办法
259
查看次数