如何以編程方式在gridview中添加複選框字段,我的代碼有什麼問題?如何在GridView中添加CheckBox字段?
try
{
string [email protected]"Data Source=A-63A9D4D7E7834\SECOND;";
string [email protected]"Initial Catalog=replicate;";
string [email protected]"User ID=sa;";
string [email protected]"Password=two";
string full_con=Data_source+Initial_Catalog+User+Password;
SqlConnection connection = new SqlConnection(full_con);
connection.Open();
SqlCommand numberofrecords = new SqlCommand("SELECT COUNT(*) FROM dbo.Table_1", connection);
DataSet ds2 = new DataSet();
SqlDataAdapter testadaptor = new SqlDataAdapter();
testadaptor.SelectCommand = new SqlCommand("SELECT COUNT(*) FROM dbo.Table_1", connection);
testadaptor.Fill(ds2);
grid1.DataSource = ds2;
CheckBoxField c = new CheckBoxField();
grid1.Columns.Add(c);
grid1.DataBind();
numberofrecords.Dispose();
connection.Close();
connection.Dispose();
}
catch (Exception a)
{
Response.Write("Please check ");
Response.Write(a.Message.ToString());
Response.Write(a.Source.ToString());
}//catch
nope,這不起作用,它不應該與任何東西綁定 – user287745 2010-10-24 04:37:21
好吧,我現在看到。修改我的答案。 – Bitwise 2010-10-24 22:30:21
這個複選框會在選中時幫助我檢測它所屬的行嗎? – user287745 2010-10-25 19:28:34