pinki
pinki

Reputation: 1418

DetailsView not showing

I have a gridview add a link button "Edit":

<asp:LinkButton ID="btnViewDetails" runat="server" text="Edit" CommandName="Select"></asp:LinkButton>

and

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (var dataContext = new NewsStandAloneDataContext(Config.StandaloneNewsConnectionString))
            {
                DetailsView1.ChangeMode(DetailsViewMode.Edit);
                DetailsView1.Visible = true;
                var dataList =
                    dataContext.sp_Name(Convert.ToInt32(GridView1.SelectedValue), Value1);
                ScriptManager.RegisterStartupScript(this, GetType(), "show1", "openEditWindow();", true);
                DetailsView1.DataSource = dataList;
                DetailsView1.DataBind();
            }
        }

But my details view does not show anything.

Upvotes: 0

Views: 539

Answers (1)

Mitchel Sellers
Mitchel Sellers

Reputation: 63126

Looking at your code you have two different methods in play. In your ViewDetails button you are referencing a command name and argument. In your other block of code you are responding to the changing of the selected row. Two different concepts.

You would want to show the details view from the "ItemCommand" event, and not the selectedindexchanged event.

Upvotes: 1

Related Questions