Hi,
I have two visual webparts named provider and consumer. In provider there is a textbox and a button. I want to send textbox value to consumer which is a gridview and which should filled up accordingly.
On consumer there is a dropdown with autopostback = true. If I dont pass value from textbox in provider, this dropdown should work for filling up the gridview.
Now the problem:
When at the first time I pass some value from textbox, the consumer is refreshed. But when I select any item from dropdown, it is posted back, but again shows the first item of the dropdown and grid is not refreshed.
My code in consumer:
Code:
protectedoverridevoid OnPreRender(EventArgs e)
{
try
{
base.OnPreRender(e);
if (_provider != null)
{
if (_provider.CaseNo != "")
{
HttpContext.Current.Session["CaseNo"] = _provider.CaseNo; //This is used by method which is filling the gridview in codebehind of visual webpart's ascx.cs file
Label lbl = newLabel();
lbl.Text = " : " + _provider.CaseNo;
this.Controls.Add(lbl);
}
Control control = Page.LoadControl(_ascxPath);
Controls.Add(control);
}
}
catch (Exception ex)
{ }
}
The label always shows the value of textbox, even if I did not click to button in provider (I think on every postback the value from provider is sent to consumer)
PLEASE HELP.
Thanks
Nitin