hi
I have a ultrawebgrid and and on each row I have 5 webcombos placed into the 5 of the Cells which works perfectly. Each webcombo consists of 2 columns an ID, Description and is bound by a Datatable whicd I create and fill in code. I have set the datatextfield to equal the description so it displays the Text in the webgrid cell when a webcombo option is selected and the datavaluefield to be the ID but when ever i run the AddNewRow which is done on click on a button in the aspx page and runs the AddnewRow on server side which works fine, this causes a postback, but on postback all the cells which were webcombos now display the ID and not the Text field and i want the text value displayed not the ID anybody any ideas how i can do this. My ultrawebgrid is a user control dropped into an ASPX page and the AddNewRow button is not on the user control but on the parent aspx page if this helps. I must save the values as the ID though but want to display the text value to user not the ID.
thanks
Leigh, I have the exact same problem.
One workaround is to do a redirect back to the original page once the Update has been processed this will force the grid to reload and display the combos correctly again. An added bonus is that forcing the redirect means that if the user does a refresh of the page they will not issue the postback again and wont get the "resend information you previously submitted" warning.
However this only works if the update is successful, if it fails for some reason (e.g. due to server side validation) ideally you want to leave the user on the same page, report the error and allow them to correct their inputs before pressing update again. This is exactly my scenario, and like you, the webcombos in my grid are failing to initialize correctly on the postback. One for infragistics I think.
Thanks
Okay
I have just now fixed my problem. The issue was the WebCombo was not maintaining its data across the postbacks. With a conventional ASP drop down list the items once added on page load will be maintained in ViewState on subsequent post backs. The IG webcombo does not follow this pattern: it loses state on postback. The way I fixed this was by ensuring I rebind the datasource of the webcombo on PostBack. In my case I simply queried the data on page load and stuck it in the session and then rebind it on all subsequent page requests:
'---------------------------------------------------------------------------- ' Page_Load '---------------------------------------------------------------------------- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If (Not IsPostBack) Then Session("BrandCbo") = ... get the data initially here End if End Sub
'---------------------------------------------------------------------------- ' dcbo_Brand_InitializeDataSource '---------------------------------------------------------------------------- Protected Sub dcbo_Brand_InitializeDataSource(ByVal sender As Object, _ ByVal e As Infragistics.WebUI.WebCombo.WebComboEventArgs) _ Handles dcbo_Brand.InitializeDataSource
' this code will be fired on all page requests If (Not IsNothing(Session("BrandCbo"))) Then dcbo_Brand.DataValueField = "Brand_PK" dcbo_Brand.DataTextField = "BrandName" dcbo_Brand.DataSource = Session("BrandCbo") dcbo_Brand.DataBind() End If
End Sub
I hope this helps.