Cannot set label.Text values in a modal popup from GridView values (in BoundFields)

廉价感情. 提交于 2019-12-12 02:19:28

问题


I have a GridView with several BoundFields from a compact SQL database (I am using the older Visual Studio Express 2010, in C#)

I am experimenting, and have read that if your GridView fields are BoundFields rather than Template, extraction of the value should be as easy as:

Label.Text = GridView1.SelectedRow.Cells[0].Text;

(considering you are aiming for the value of the selected row)

I am trying to show that value in a Modal Popup Extender, and it's showing blank. No error message at all, and the debugger just shows the value blank all the time. Since I am quite a beginner, I am guessing that probably my error is in the placement of the parts, but I couldn't figure it out:

My GridView definition has this:

onselectedindexchanged="GridView1_SelectedIndexChanged"

Then later on I have a Panel with a Modal Popup Extender:

<asp:Panel ID="view" runat="server" CssClass="pnlBackGround">
    <asp:Label ID="vid" runat="server" ></asp:Label>
    <asp:Button ID="vclose" runat="server" Text="Cerrar" />
</asp:Panel>


<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender2" 
     PopupControlID="view" 
     OkControlID="vclose" 
     TargetControlID="f1" 
     BackgroundCssClass="modalBackground"
     runat="server">
</ajaxToolkit:ModalPopupExtender>

And the function that is giving me problems is the one called on selected index changed:

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
 vid.Text = GridView1.SelectedRow.Cells[0].Text;
 this.ModalPopupExtender2.Show();
 }

I think that this code should grab the value of the first cell of the selected row, and place it as text of the "vid" label, and then open the popup extender with that information.

What (probably silly) thing am I doing wrong?

来源:https://stackoverflow.com/questions/30673256/cannot-set-label-text-values-in-a-modal-popup-from-gridview-values-in-boundfiel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!