<asp:DataGrid ID="dbStaffList" runat="server" OnPageIndexChanged="DataGrid_PageChanged"
BorderColor="#93BEE2" BorderStyle="None" BorderWidth="1px" BackColor="White"
CellPadding="3" PageSize="15" AllowPaging="True" AutoGenerateColumns="False"
DataKeyField="Staff_ID" Width="100%">
<SelectedItemStyle Font-Bold="True" ForeColor="#CCFF99" BackColor="#009999"></SelectedItemStyle>
<AlternatingItemStyle Font-Size="12px" BackColor="#E8F4FF"></AlternatingItemStyle>
<ItemStyle Font-Size="12px"></ItemStyle>
<HeaderStyle Font-Size="12px" Font-Bold="True" ForeColor="White" BackColor="#337FB2"
HorizontalAlign="Center"></HeaderStyle>
<FooterStyle Font-Size="12px" HorizontalAlign="Right" BackColor="#E8F4FF"></FooterStyle>
<Columns>
<asp:TemplateColumn HeaderText="ID">
<HeaderStyle Width="20px"></HeaderStyle>
<ItemTemplate>
<asp:CheckBox ID="chkStaff_ID" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:HyperLinkColumn Text="真实姓名" DataNavigateUrlField="staff_id" DataNavigateUrlFormatString="../position/NewStaff.aspx?StaffID={0}&ReturnPage=1"
DataTextField="RealName" HeaderText="真实姓名">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField="Mobile" HeaderText="手机">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
</Columns>
<PagerStyle Font-Size="X-Small" HorizontalAlign="right" BackColor="#E8F4FF" Mode="NumericPages">
</PagerStyle>
</asp:DataGrid>
//
private string GetSelectedItemID(string controlID)
{
string selectedID;
selectedID = "";
//遍历DataGrid获得checked的ID
foreach (DataGridItem item in dbStaffList.Items)
{
if(((CheckBox)item.FindControl(controlID)).Checked==true )
selectedID += dbStaffList.DataKeys[item.ItemIndex] + ",";
}
if(selectedID.Length>0)
selectedID=selectedID.Substring(0,selectedID.Length-1);
return selectedID;
}
private string GetSelectedItemID1(string controlID)
{
string selectedID;
selectedID = "";
//遍历DataGrid获得checked的ID
foreach (DataGridItem item in dbStaffList1.Items)
{
if (((CheckBox)item.FindControl(controlID)).Checked == true)
//selectedID += dbStaffList1.DataKeys[item.ItemIndex] + ",";
selectedID += item.Cells[1].Text.ToString() + ",";
}
if (selectedID.Length > 0)
selectedID = selectedID.Substring(0, selectedID.Length - 1);
return selectedID;
}