look:
------------------------
StringBuilder str=new StringBuilder(100);
for(int i=0;i<DataGrid1.Items.Count;i++)
{
CheckBox Select=(CheckBox)DataGrid1.Items[i].FindControl("CheckBox1");
if (Select.Checked==true)
{
System.Web.UI.WebControls.DataGridItem dgi=this.DataGrid1.Items[i];
str.Append(dgi.Cells[1].Text.Trim()+","+dgi.Cells[2].Text.Trim());
str.Append("*");
}
else
{
}
}
string s=str.ToString();
s=s+"";
------------------------
StringBuilder str=new StringBuilder(100);
for(int i=0;i<DataGrid1.Items.Count;i++)
{
CheckBox Select=(CheckBox)DataGrid1.Items[i].FindControl("CheckBox1");
if (Select.Checked==true)
{
System.Web.UI.WebControls.DataGridItem dgi=this.DataGrid1.Items[i];
str.Append(dgi.Cells[1].Text.Trim()+","+dgi.Cells[2].Text.Trim());
str.Append("*");
}
else
{
}
}
string s=str.ToString();
s=s+"";
<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False" Width="267px" CellSpacing="1" CellPadding="0">
<HeaderStyle HorizontalAlign="Center" BackColor="#DDDDD5"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="选择">
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn Visible="False" DataField="carcode" HeaderText="编码"></asp:BoundColumn>
<asp:BoundColumn DataField="carno" HeaderText="车号"></asp:BoundColumn>
<asp:BoundColumn DataField="carowner" HeaderText="产权人"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
{
CheckBox chk = ( CheckBox )DataGrid1.Items[i].FindControl("chkFile");
if( chk.Checked )
{
Response.Write( DataGrid1.DataKeys[DataGrid1.Items[i].ItemIndex].ToString() );
}
}
http://expert.csdn.net/Expert/topic/1502/1502905.xml?temp=.7607843