views:

783

answers:

2

I have a gridview that is only shown in a modal popup. right before I call the modal popup I set a value in a textbox. The gridview inside the modal popup depends on that textbox's value for it's data to show up at all. SO onclick I want to reload the gridview so that it will reload with the textbox's value. Any ideas?

A: 

Put popup window content (grid and the rest there is) in separate aspx page and then when you initialize popup window, send textbox value as parameter:

MyPopupWindowContent.aspx?TextBoxValue=something
zendar
+4  A: 

Essentially... Using update panel, the button press event should trigger the partial postback where your query is rerun that would then allow you to do another databind on your grid. THis would all be followed by a modalPopUp.Show()...

CODE BEHIND

protected void btnAdd_Click(object sender, EventArgs e)
{
    if(!String.IsNullOrEmpty(this.txtMyValue.Text))
    {
         AddValue(this.txtMyValue.Text);
         UpdateGrid();
         this.UpdatePanel1.Update();
    }
    else
    {
       //ooooops
    }
}

private void AddValue(String str)
{
   DataAccess.AddSomeValue(str);
}

private void UpdateGrid()
{
   this.GridView1.DataSource = DataAccess.GetData();
   this.GridView1.DataBind();
}

FRONT END

<asp:UpdatePanel ID="UpdatePanel1" runat="server" updatemode="Conditional">
    <ContentTemplate>
        <asp:TextBox id="TextBox1" runat="server" />
        <asp:Button id="btnAdd" OnClick="btnAdd_Click" runat="Server">
        <div id="MyModalArea">
           <asp:GridView id="GridView1" runat="Server" ..... >
           </asp:GridView>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
RSolberg
I did use AJAX framework. The relationship is that I set up the gridview using a datasource but not programmatically. The sql statment says 'Select data from tbl where Dept = Textbox.text' the Textbox value doesn't get set until the OnclientClick is fired which is why i want to attempt to reload just that grid. Is that clear? Is this possible?
Eric
Yep... Just need to fire off the events like I've done above, just replace the functions with your selects, etc.
RSolberg
how do i get Access to that DataAccess Method? I'm using VB.net but There is no language barrier.
Eric
I simply put that in there to show if you were to work with some middle class that handled your DB connections.
RSolberg
ok I used your technique. Except that I set the textbox data using Javascript. My only issue is that it submits the page. The Modalpopup shows up but i don't like the page submitting. Is it possible to stop that entire submit after the ModalPopup is called?
Eric
Which modal popup are you using?
RSolberg