GridView
を使用してから行を削除する方法を教えてくださいLinkButton
。Google で見つけたコードは、 databound を使用していますGridView
。で選択した情報に応じて情報をバインドしていDropDownList
ます。ありがとう
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string username;
username = HttpContext.Current.User.Identity.Name;
if (DropDownList1.SelectedValue.Equals("Expired"))
{
SqlConnection conn4 = new SqlConnection(My connection);
SqlDataAdapter adapter;
string mySQL2;
mySQL2 =
"SELECT Title,MessageStatus From Table_Message WHERE Username ='"
+ username
+ "' AND MessageStatus = 'Expired' AND Method = 'Email'";
adapter = new SqlDataAdapter(mySQL2, conn4);
conn4.Open();
DataSet ds3 = new DataSet();
adapter.Fill(ds3);
//Execute the sql command
GridView1.DataSource = ds3;
GridView1.DataBind();
conn4.Close();
}
else if (DropDownList1.SelectedValue.Equals("Pending"))
{
SqlConnection conn3 = new SqlConnection(My connection);
SqlDataAdapter adapter1;
string mySQL;
mySQL =
"SELECT Title,MessageStatus From Table_Message WHERE Username ='"
+ username
+ "' AND MessageStatus = 'Pending' AND Method = 'Email'";
adapter1 = new SqlDataAdapter(mySQL, conn3);
conn3.Open();
DataSet ds2 = new DataSet();
adapter1.Fill(ds2);
//Execute the sql command
GridView1.DataSource = ds2;
GridView1.DataBind();
conn3.Close();
}