Saturday, March 24, 2012

put an AutoPostBack=true control inside a updatepanel?

Hi, All:

Just upgrade to AJAX. Everything works greate. Maybe this is a simple question.

I have a gridview which is inside in a updatepanel. then I have an dropdownlist inside a ItemTemplate of my GridView and this the autopostback attribute of this ddl is set to true. I have a onselectedindexchanged event to do something and refresh the gridview (old fashion way). Does this autopostback= true will refresh the whole page ( I have other controls on this page except theis gridview). I tried and It looks like it just refresh the gridview only. Am I right? If I set the autopostback=false, then nothing happened. I can not put this ddl into Triggers since it is an control in the itemtemplate of the gridview

Another question, with this ddl index changed event, I want to change partial of the gridview only, say show or hide a label in another itemtemplate, what should I do? put the updatepanel inside the itemtemplate??

Thanks

-rockdale

Hello rockdale,

Question: *** I tried and It looks like it just refresh the gridview only. Am I right? ***
YES, since it's inside the UpdatePanel. Leave your AutoPostBack=True.

Question: *** I want to change partial of the gridview only, say show or hide a label in another itemtemplate ***
Step1: *** onselectedindexchanged event to do something and refresh the gridview (old fashion way). ***

Sample:
<asp:gridview id="gridview1"... >
<columns>
<asp:templatefield>
<itemtemplate>
<asp:Label id="lblName" Text="John Smith" runat="server" />
</itemtemplate>
...

At Step1, you can hide or show part of your gridview.

dim ctrl as control
ctrl = controlfinder.fincontrol(me.gridview1, "lblName")
if not ctrl is nothing then
ctype(ctrl, label).visible = true or false
end if

WS


No comments:

Post a Comment