如何在GridView中获取复选框ID [英] How to get the checkbox id in the gridview

查看:71
本文介绍了如何在GridView中获取复选框ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的应用程序中,我使用带有更新面板的gridview控件.在那个gridview中,我使用了1个Checkbox控件和三个下拉菜单.对于复选框,我具有checkedchanged事件,对于所有三个下拉菜单,我具有选定的索引更改事件.选中此复选框后,事件将触发并且页面正在刷新.下拉控件也是如此.我的问题是我想更改选定的索引,并且应该在不刷新页面的情况下发生选中的更改事件.我已经尝试为该控件提供异步回发触发器,但是它没有用.谁能帮我解决这个问题.这是代码:

Hi,

In my application I am using the gridview control with update panel. In that gridview I am using 1 Checkbox control and three dropdown. For check box I am having the checkedchanged event and for all the three dropdown I am having the selected index change event . When the check box is checked the event is firing and the page is refreshing. And the same happens for the dropdown control. My problem is I want to make the selected index change and checked change event should happen without refreshing the page. I have tried giving the asynchronous post back trigger for that controls, but it not worked. Can anyone please help me to solve this problem. Here is the Code:

<table align="center" class="css_MainTable">
                                <tr>
      <td align="center" colspan="2">
          <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
              <ContentTemplate>
                  <asp:GridView ID="gvTenderTeam" runat="server" AutoGenerateColumns="False"
                      CssClass="css_gridview" GridLines="Vertical"
                      onrowdatabound="gvTenderTeam_RowDataBound"
                      onrowdeleting="gvTenderTeam_RowDeleting" onrowediting="gvTenderTeam_RowEditing"
                      onselectedindexchanged="gvTenderTeam_SelectedIndexChanged" >
                      <PagerSettings FirstPageText="First" LastPageText="Last"
                          Mode="NextPreviousFirstLast" NextPageText="Next" PreviousPageText="Previous" />
                      <RowStyle CssClass="css_gridview_rowstyle" />
                      <Columns>
                          <asp:TemplateField HeaderText="Select">
                              <ItemTemplate>
                                  <asp:CheckBox ID="chkSelect" runat="server" AutoPostBack="True"
                                      Checked=''<%# Eval("SelectId").ToString().Equals("Y") %>''
                                      oncheckedchanged="chkSelect_CheckedChanged" />
                              </ItemTemplate>
                          </asp:TemplateField>
                          <asp:TemplateField HeaderText="Sl No" SortExpression="EmployeeCode">
                              <ItemTemplate>
                                  <asp:Label ID="lblSlNo" runat="server" CssClass="css_GridLabel"
                                      Text=''<%# Bind("SlNo") %>''></asp:Label>
                              </ItemTemplate>
                              <ItemStyle HorizontalAlign="Center" />
                          </asp:TemplateField>
                          <asp:TemplateField HeaderText="Risk Type">
                              <ItemTemplate>
                                  <asp:DropDownList ID="ddlRiskType" runat="server" AutoPostBack="True"
                                      onselectedindexchanged="ddlRiskType_SelectedIndexChanged" TabIndex="2"
                                      Width="150px">
                                      <asp:ListItem>--Select--</asp:ListItem>
                                      <asp:ListItem Value="F">Financial(Projects)</asp:ListItem>
                                      <asp:ListItem Value="R">Financial(Credit)</asp:ListItem>
                                      <asp:ListItem Value="C">Contractual</asp:ListItem>
                                      <asp:ListItem Value="M">Commercial</asp:ListItem>
                                      <asp:ListItem Value="T">Technical</asp:ListItem>
                                      <asp:ListItem Value="X">Execution</asp:ListItem>
                                  </asp:DropDownList>
                              </ItemTemplate>
                          </asp:TemplateField>
                          <asp:TemplateField HeaderText="Functional Role">
                              <ItemTemplate>
                                  <asp:DropDownList ID="ddlFunctionalRole" runat="server" AutoPostBack="True"
                                      DataTextField="__designer:mapid="60e""
                                      onselectedindexchanged="ddlFunctionalRoleCode_SelectedIndexChanged"
                                      TabIndex="3" Width="150px">
                                  </asp:DropDownList>
                              </ItemTemplate>
                          </asp:TemplateField>
                          <asp:TemplateField HeaderText="Employee Name">
                              <ItemTemplate>
                                  <asp:DropDownList ID="ddlEmployeeCodeAdd" runat="server" AutoPostBack="True"
                                      TabIndex="4" Width="150px"
                                      onselectedindexchanged="ddlEmployeeCodeAdd_SelectedIndexChanged">
                                  </asp:DropDownList>
                              </ItemTemplate>
                          </asp:TemplateField>
                          <asp:TemplateField HeaderText="Error Description" Visible="False">
                          <ItemTemplate>
                           <asp:Label id="lblError" runat="server"
                                  Text=''<%# DataBinder.Eval(Container.DataItem, "Error") %>''
                                  ForeColor="#CC0000" Width="150px" Font-Bold="True" ></asp:Label>
                          </ItemTemplate>


                          </asp:TemplateField>
                          <asp:TemplateField HeaderText="keydata" Visible="False">
                              <ItemTemplate>
                                  <asp:Label ID="lblKeydata" runat="server"
                                      Text=''<%# DataBinder.Eval(Container.DataItem, "keydata") %>''></asp:Label>
                              </ItemTemplate>
                          </asp:TemplateField>
                      </Columns>
                      <PagerStyle CssClass="css_GridViewPagerStyle"
                          HorizontalAlign="Left" Wrap="False" />
                      <SelectedRowStyle CssClass="css_gridview_Selectrowstyle" />
                      <HeaderStyle CssClass="css_gridview_HeaderStyle" />
                      <EditRowStyle CssClass="css_gridview_Editrowstyle" />
                      <%--<AlternatingRowStyle CssClass="css_gridview_Altrowstyle" />--%>
                  </asp:GridView>
              </ContentTemplate>
          </asp:UpdatePanel>
      </td>
  </tr>



                              </table>


在Advance中致谢


Thanks in Advance

推荐答案

尝试做:
AutoPostBack="false"



否则调用javascript函数并返回false



else call a javascript function and return false


在您需要的事件上调用更新面板的更新方法
call the update method of update panel on your required events


在您的事件上调用更新面板的更新方法必需的事件



设置autopostback ="False"
call the update method of update panel on your required events

OR

Set autopostback="False"


这篇关于如何在GridView中获取复选框ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆