Hai Pupils,
I am a beginner in Dot net Domain.Presently Im creating a web portal for one of our client.In my portal i have displayed the News headline and a button for details in a Grid view. when i click on the button it has to show the detailed news from DB in another grid view. I have done a code on it.,but it shows some error.I have displayed the code below.Please help me to overcome this problem.
My Code IS
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType != DataControlRowType.Header && e.Row.RowType != DataControlRowType.Footer && e.Row.RowType != DataControlRowType.Pager) { Button btn = (Button)e.Row.FindControl("Button12"); btn.CommandArgument = e.Row.RowIndex.ToString(); } } protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "newsbtn") { int index = int.Parse(e.CommandArgument.ToString()); string key = GridView2.DataKeys[index].Value.ToString();
SqlDataAdapter da = new SqlDataAdapter("select **img,news,detail** from News where news=@n", connect.con());
da.SelectCommand.Parameters.AddWithValue("@n", key);
da.Fill(ds, "more");
//if (!IsPostBack)
//{
GridView1.DataSource = ds;
GridView1.DataBind();
//}
}
}
The error it shows is:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'detail'.