When I put a breakpoint in the gridview_SelectedIndexChanged, it goes into this method correctly, and I can hover over SummaryLabel to see its properties, but the label never shows up. When I press F12 to see the code while the page is running, I can't see
my label.
This should be a simple enough thing, I would have thought!
In fact you should have a selectable LinkButton, button or image button whose name is "Select"——by setting CommandName=Select.
[aspx]
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="WebForm1.aspx.cs"Inherits="CSharp.WebForm1"%><!DOCTYPEhtml><htmlxmlns="http://www.w3.org/1999/xhtml"><headid="Head1"runat="server"><metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/><title></title></head><body><formid="form1"runat="server"><div><asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager><br/><asp:UpdatePanelrunat="server"ID="gridPanel"><ContentTemplate><asp:GridViewID="GridView1"runat="server"SkinID="Grid"AutoGenerateColumns="False"OnSelectedIndexChanged="gridview_SelectedIndexChanged"><Columns><asp:TemplateFieldHeaderText="Course"><ItemTemplate><asp:LabelID="lbText"runat="server"Text='<%#Eval("Name") %>'/><asp:LinkButtonText="Select"CommandName="Select"runat="server"/></ItemTemplate></asp:TemplateField></Columns></asp:GridView><br/><asp:LabelID="SummaryLabel"runat="server"Text="This is the summary label"Visible="false"/></ContentTemplate></asp:UpdatePanel></div></form></body></html>
ASPdeveloper...
Member
3 Points
26 Posts
Label not being displayed
Nov 23, 2012 03:04 PM|LINK
Hi,
I am displaying a label with information when a row is clicked in a gridview.
Here is the code for the gridview:
<asp:UpdatePanel runat="server" ID="gridPanel"> <ContentTemplate> <asp:GridView ID="retrieved" runat="server" SkinID="Grid" onrowdatabound="GridViewRowCreatedHandler" AutoGenerateColumns="False" onselectedindexchanged="gridview_SelectedIndexChanged"> <Columns> <asp:TemplateField HeaderText="Course" > <ItemTemplate> <asp:Hyperlink ID="editCourse" onclick="opendialogwindow(this); return false;" Text='<%# Eval("CourseName") %>' NavigateUrl='<%# Eval("CourseUrl") %>' Target="_new" runat = "server" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </ContentTemplate> </asp:UpdatePanel> <asp:Label ID="SummaryLabel" runat="server" Text="This is the summary label" Visible="false" ></asp:Label>The SummaryLabel is the one I want to display once a row is clicked on.
Here is the code for the gridview_SelectedIndexChanged in teh aspx.cs page, which should display the label:
protected void gridview_SelectedIndexChanged(object sender, EventArgs e) { try { if (gridview.SelectedIndex >= 0) { SummaryLabel.Text = "TEST!!!!!"; SummaryLabel.Visible = true; } } catch (Exception ex) { string message = ""; message = ex.ToString(); } }When I put a breakpoint in the gridview_SelectedIndexChanged, it goes into this method correctly, and I can hover over SummaryLabel to see its properties, but the label never shows up. When I press F12 to see the code while the page is running, I can't see my label.
This should be a simple enough thing, I would have thought!
Thanks.
anil.india
Contributor
2613 Points
453 Posts
Re: Label not being displayed
Nov 23, 2012 03:27 PM|LINK
You need to handle to it in this way -
http://abhijitjana.net/2010/06/14/how-to-update-controls-which-are-outside-of-updatepanel-during-partial-page-rendering/
http://forums.asp.net/t/1120428.aspx
codepattern.net/blog ||@AnilAwadh
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Label not being displayed
Nov 24, 2012 04:17 AM|LINK
Hello,
In fact you should have a selectable LinkButton, button or image button whose name is "Select"——by setting CommandName=Select.
[aspx]
[cs]
ASPdeveloper...
Member
3 Points
26 Posts
Re: Label not being displayed
Nov 26, 2012 12:55 PM|LINK
Thanks for your help!