gvidview中有checkbox列,"申请时间"、"类型"列...
其中,checkbox模板列头放了一个按钮“导出“,类型列只有两个值类型1和类型2
如: <asp:GridView ID="GVList" runat="server"  Width="100%" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" AutoGenerateColumns="False"  AllowPaging="True" OnPageIndexChanging="GVList_PageIndexChanging" PageSize="30" OnRowDataBound="GVList_RowDataBound" >                        
<Columns>                
  <asp:TemplateField >
    <HeaderTemplate>
      <asp:Button ID="btnimport" runat="server" SkinID="ButtonSkin"  Text="导出" CommandName="import" OnClick="btnimport_Click" />
    </HeaderTemplate>
   <ItemTemplate>
   <asp:CheckBox ID="GVchkbox" runat="server" SkinID="CheckBoxSkin" Checked='<%# Bind("chk") %>'  AutoPostBack="false" />                                                  
   </ItemTemplate>
</asp:TemplateField>
...
当点导出按钮时,传一个DATATABLE,到另一个页面。
要求:当用户选择记录时,若混选(即有类型1,也有类型2),则弹出对话框,提示用户是否确认混选,若用户选择是,则进入下一个页面,否则不进行操作。
问题是我不能很好的控制何时弹出对话框。
我在page_load()事件里进行判断,如果选择的记录中有混选现象时,即:
 for (int i = 0; i < dr.Length-1; i++)
{
 if (dr[i]["typecd"].ToString().Trim() != dr[i + 1]["typecd"].ToString().Trim())
  {
   SystemContant.flag = "1";
   break;
  }
}
if (SystemContant.flag == "1")
  {
   SystemContant.flag = "0";
   GVList.HeaderRow.Cells[0].Attributes.Add("onclick", "if(!confirm('确认混选,申请购买?')) return false");
 }
其中SystemContant.flag 初值为"0";dr是datarow[],为所有选择的记录组。
向各位求助,谢谢!