protected void ShowDataNews(int SelectIndex)
{
Label5.Text = (index+1).ToString();
SqlConnection conn = new SqlConnection(@"Server=(local)\sqlexpress;uid=sa;pwd=1111;database=webdatabase");
SqlDataAdapter da = new SqlDataAdapter(@"select * from news order by newsid desc", conn);
SqlDataAdapter daKind = new SqlDataAdapter(@"select * from kind", conn);
SqlDataAdapter daTeam = new SqlDataAdapter(@"select * from team", conn);
if(ds.Tables["news"]==null)
{
conn.Open();
da.Fill(ds, "news");
daKind.Fill(ds, "kind");
daTeam.Fill(ds, "team");
conn.Close();
}
//da.Update(ds, "news");
ds.AcceptChanges();
try
{
TextBox8.Text = ds.Tables["news"].Rows[SelectIndex][1].ToString();
TextBox9.Text = ds.Tables["news"].Rows[SelectIndex][2].ToString();
DropDownList5.DataSource = ds.Tables["kind"];
DropDownList5.DataTextField = "kind_name";
DropDownList5.DataValueField = "kind_id";
DropDownList5.DataBind();
DropDownList5.SelectedValue = ds.Tables["news"].Rows[SelectIndex][4].ToString();
DropDownList6.DataSource = ds.Tables["team"];
DropDownList6.DataTextField = "teamname";
DropDownList6.DataValueField = "teamid";
DropDownList6.DataBind();
DropDownList6.SelectedValue = ds.Tables["news"].Rows[SelectIndex][5].ToString();
if (index > ds.Tables["news"].Rows.Count - 2)
{
index = ds.Tables["news"].Rows.Count - 1;
Button12.Visible = false;
}
if (index == 0)
{
index = 0;
Button11.Visible = false;
}
}
catch (System.Exception ex)
{
}
int dscount = ds.Tables.Count;
Response.Write(dscount.ToString() + "//");
}
这是绑定代码,用button执行,不显示啊。