Showing posts with label input. Show all posts
Showing posts with label input. Show all posts

Monday, March 26, 2012

tab control and modelpopup

In my form aspx page, I have three panels, top of the page I have three input buttons controls how I display my panels, first button display panel1(hides panel2 and 3) , second button displays panel2(hides panel1 and panel3), third panel display panel3(hides panel1 and 2).

Only thing is, panel2 has one small subpanel and datagrid in it that for datagrid, I put a modelpopupextender , because I wanted when user clicks linkbutton inside the datagrid, I make modelpopup pops. That means it I have update panel inside the Panel2 already.

I have tried some javascript functions for displaying/hiding my panels when buttons are clicked, but I needed also for panel2 when user saves datagrid, page refreshes and needs to comes back to show panel2 again,it was keep showing panel1, I put some javascript for that would remember last button clicked, so could come back that one, but that gives me some problem, so maybe I should try Ajaxs Tab , but I get confused how would I set up that, because I already have updatepanel inside the panel2 for modelpopup, so how would I can put tab control for whole form? Would it effect Tab and modelpop up together ?

Any suggestions?

Hi,

I agree your idea of trying to use TabContainer control. With it, you don't need to worry about keep its state between postbacks.

For more information about how to use it, I'd suggest downloading the sample web sitehere and try the tabs page.

Wednesday, March 21, 2012

Tabcontainer in formview - not inserting data

i am using a tabcontainer and panels inside the insertitemtemplate of a formview.

When i input text in the field and do an insert, a new record is created in the database, but the inputted fields are not processed??

If i place one textfield outside of the tabcontainer, the insert is working.

So, my question is: Is it not possible to use a tabcontainer IN a formview or do i need a workaround?

Maybe i just need to do it by inserting it manually, but then my question is, how do i get the inputted values from the formview?

Thanx for your help

Maurice

Hi Multje,

I had a similar issue when trying to use a dropdownlist bound to a sqldatasource AND the same dropdownlists selected value bound to the formview's datasource. I couldn't have it both ways, so I had to come up with a workaround.

Your situation is that the items in the tabcontainer would have to be referenced using the FindControl() method, which is not a built-in process in the formview... so your workaround will need to be similar to that which I used.

I put a hiddenfield in the formview, and when my dropdownlist selection changed, I put the selected item value into the hidden field. The formviews datasource was two-way bound to the hiddenfield, and not the dropdownlist itself.

What you will need to do is trigger the population of the hiddenfield's value in the formview when you do something within your tabcontainer. Get what I am saying? That way, the formview wont need to dig through the tabcontainer... it will use the hiddenfield. The hiddenfield will be populated by by your actions within the tabcontainer.


Hi,

thanx for the response.

I understand the workaround, however, in my case i dont have any dropdowns, just textboxes that are filled in by the user. I really cant understand why the formview, with the tabcontainer within in, containing the same fields as the formview normally has, databound and all, doesnt insert the values in the database? And the workaround in my case would be a lot of work to do, since my table has got about 35 fields to fill! That would mean i need 35 hidden fields as well??!!

There must be a better solution to this! :-)

Maurice


hi,

in code i found a way to make it work:

Protected

Sub BookTemplateDetail_OnIteminserting(ByVal senderAsObject,ByVal eAs System.Web.UI.WebControls.FormViewInsertEventArgs)Handles BookTemplateDetail.ItemInserting
Dim pAsNew TextBox
Dim SelTabContainerAsNew TabContainer
Dim SelTabPanelAsNew TabPanel

e.Cancel =True
Try
SelTabContainer = BookTemplateDetail.FindControl("TabContainer1")
SelTabPanel = SelTabContainer.FindControl("TabPanel1")
p = SelTabPanel.FindControl("new_tbook_template_naamTextBox")
dbStatus.Text = p.Text
Catch exAs Exception
dbStatus.Text ="Failed!"
EndTry
EndSub

this works, but MY GOD! I have 30 fields on this form (on 3 tabpanels). Do i need to find all af them, put them in separate strings and then call the insert method??

Any suggestions?


Hello guys, i've found a solution

Protected

Sub FvLodge_ItemUpdating(ByVal senderAsObject,ByVal eAs System.Web.UI.WebControls.FormViewUpdateEventArgs)Handles FvLodge.ItemUpdatingDim lodgeNombre, lodgeObservaciones, lodgePropiedadMLP, lodgeActivoAsStringDim lodgeNoches, lodgeHabitaciones, lodgeCapMaxHab, idUsuarioModificadorAsIntegerDim SelTabContainerAsNew TabContainerDim SelTabPanelAsNew TabPanelTry

SelTabContainer = FvLodge.FindControl(

"TbcDatosLodge")

SelTabPanel = SelTabContainer.FindControl(

"PnlDatos")

lodgeNombre =

CType(SelTabPanel.FindControl("TxtLodgeNombre"), TextBox).Text-->here i capture the value in the textbox that is inside the tabpanel

e.NewValues.Add(

"LodgeNombre", lodgeNombre) -->and here i pass that value as aNewValueto the collection of new values, is is important that the key name must be the same as in your update or insert queryCatch exAs Exception

e.Cancel =

TrueEndTryEndSub

hope this helps!..