Detailsview does not display
I have a master-detail view. In the gridview I have a开发者_StackOverflow中文版 button
<asp:LinkButton ID="btnViewDetails" runat="server" text="Edit" CommandName="Select" CommandArgument='<%# Eval("BoundFieldId") %>'></asp:LinkButton>
Now in the RowCommand, I did
DetailsView1.ChangeMode(DetailsViewMode.Edit);
if (e.CommandName.Equals("Select"))
{
var value = Convert.ToInt32(e.CommandArgument);
using (var dataContext = new xxxDataContext(Config.xxxConnectionString))
{
var dataList = (from t in dataContext.tableName
where te.Id == Convert.ToInt32(value)
select t).ToList();
DetailsView1.DataSource = dataList;
DetailsView1.DataBind();
}
But I can't see my details view and it doesn't bind I guess. Why is this?
I've just tested your approach and everything seems to be fine. I guess the things to check would be:
1) Check that there is actually data with that ID in the database
2) Ensure your GridView has the "onrowcommand" event wired-up in the source view - should look something like:
<asp:GridView ID="GridView1" runat="server" onrowcommand="GridView1_RowCommand">
Can you place a breakpoint inside the onrowcommand handler?
精彩评论