Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have a linkbutton that is suppose to passes a value to a textbox,the textbox and the linkbutton are both inside a gridview . When i click the linkbutton a popup extender is executed with my textbox. Now i tried to find the textbox but stil its empty.

How can i do this?

Below is my gridview

XML
<asp:GridView  ID="grdAvailableStaff"  runat="server"  CellPadding="4"  EnableViewState="true"
               AllowPaging="True"
                PageSize="5"
               Width="423px" onrowdatabound="grdAvailableStaff_RowCreated"
               ForeColor="#333333" GridLines="None" Height="16px" DataKeyNames="FullName"

               ShowHeaderWhenEmpty="True"
                onpageindexchanging="grdAvailableStuff_PageIndexChanging"
                EmptyDataText="No Appointment Slots Created" >

               <AlternatingRowStyle BackColor="White" />

               <Columns >

              <asp:TemplateField HeaderText="Create Appointment">

            <ItemTemplate>
                <asp:LinkButton ID="createAppointment" runat="server"  OnClick="createAppointment_Click" PostBackUrl='<%# "frmFindAppointment.aspx?Fullname=" + HttpUtility.UrlEncode(Eval("Fullname").ToString())+"&RecordNumber="+ HttpUtility.UrlEncode(Eval("RecordNumber").ToString())+"&Date="+  HttpUtility.UrlEncode(Eval("Date").ToString())+"&SlotID="+ HttpUtility.UrlEncode(Eval("SlotID").ToString())+"&Timeslot="+ HttpUtility.UrlEncode(Eval("Timeslot").ToString())  %>' Text="Create Appointment" />
            <ajaxToolkit:ModalPopupExtender  BackgroundCssClass="modalBackground" ID="ModalPopupExtender1" runat="server" TargetControlID="createAppointment" PopupControlID="PNL" OkControlID="ButtonOk"  />

     <asp:Panel ID="PNL" runat="server" style="display:none; width:900px; background-color:White; border-width:2px; border-color:Black; border-style:solid; padding:20px;">
<asp:TextBox ID="txtViewPatientEmail" runat="server" 
                    ForeColor="Black" CssClass="textbox" ReadOnly="True"></asp:TextBox>
</asp:Panel>
            
            </ItemTemplate> 
        </asp:TemplateField>
                  
               </Columns>

          </ContentTemplate>
           </asp:UpdatePanel>



Below is how I reciev the passed values from my linkbutton

C#
if (Request.QueryString["FullName"] != null && !string.IsNullOrEmpty(Request.QueryString["FullName"].ToString())
              || (Request.QueryString["Slots"] != null && !string.IsNullOrEmpty(Request.QueryString["Slots"].ToString()) || (Request.QueryString["SlotsID"] != null && !string.IsNullOrEmpty(Request.QueryString["SlotsID"].ToString()))))
            {
                string SlotId = Convert.ToString((Request.QueryString["SlotsID"]));
                Session["SlotID"] = SlotId;

                string fullName = Convert.ToString((Request.QueryString["FullName"]));
                Session["FullName"] = fullName;

            }


Below is the event to populate the textbox in my popup

C#
foreach (GridViewRow row in grdAvailableStaff.Rows)
            {

                //Am looking for the control name "txtViewPatientEmail"
                string txtViewStaffName = ((System.Web.UI.WebControls.TextBox)row.FindControl("txtViewPatientEmail")).Text;
                txtViewStaffName = Session["FullName"].ToString();
}


Am expecting every time i click a link, a popup will appear with a value inside...
Posted
Updated 16-Aug-11 22:30pm
v2
Comments
Herman<T>.Instance 17-Aug-11 4:19am    
first: show your code. That helps us understand what you do

1 solution

in the onclick event of your button:

Button btn = (Button)sender;
GridViewRow row = (GridViewRow)btn.NamingContainer;


By using this code you have the gridview row in which the button was clicked.

Then:
TextBox myTextBox = (TextBox)row.FindControl("nameOfYourTextBoxHere");
if (myTextBox != null) // control is found)
     myTextBox.Text = "any text you wnat to place in the textbox";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900