Hi,I have a webgrid on page and I'm trying to do several things, this webgrid has three TemplateColumns each with a button, how can I:
a) Do a conditional redirect, i.e. if say column 6 value is '1' then go here else go hereb) During this redirect pass the IncidentID of the record as a URL parameter.c) Tell the conditional row formatting (which I have in place) to not include the first three cells (where the buttons are).Any help on any of these areas would be apprieciatedThanksMarc
Hi,
Thanks for your suggestions, my client has now opted to go in a completly different direction!
CheersMarc
For part a) do you mean do a conditional redirect when the user presses the button in one of the cells depending on the values of the other columns?
I am positive you'll be able to set this up in the InitialiseRow event for the grid ServerSide. Likely you'll have some logic which details what you've mentioned and in the end you'll be building a javascript call which you can put into the button onclick event...Something like the following perhaps:
note: i've used rubbish IDs...in case it doesn't make sense!
Protected Sub uwg_limits_InitializeRow(ByVal sender As Object, ByVal e As RowEventArgs) Handles UltraWebGrid1.InitializeRow With e.Row ' Get references to the various templated columns Dim Column1 As TemplatedColumn = CType(.Cells.FromKey("MY_TEMPLATE_COL_1").Column, TemplatedColumn) Dim Column2 As TemplatedColumn = CType(.Cells.FromKey("MY_TEMPLATE_COL_2").Column, TemplatedColumn) Dim Column3 As TemplatedColumn = CType(.Cells.FromKey("MY_TEMPLATE_COL_3").Column, TemplatedColumn) ' Hide the button that is Column 1 If MyCondition Then ' Access the cell... Dim CellItem As CellItem = CType(Column1.CellItems(e.Row.Index), CellItem) Dim btn As Button = CType(CellItem.FindControl("btn_myButton1"), Button) btn.Visible = False End If ' Make the button in Column 2 perform some javascript function ' passing a parameter from a cell If MyCondition Then ' Access the cell and button Dim CellItem As CellItem = CType(Column2.CellItems(e.Row.Index), CellItem) Dim btn As Button = CType(CellItem.FindControl("btn_myButton2"), Button) ' get the value from another cell in this row Dim Value As String = .Cells.FromKey("MY_VALUE_COL").Value ' add the javscript click event adding the ' parameter as a value from this row... ' -- since you can put whatever javascript ' function you want here...you can have your ' re-direct in the js function...window.location etc btn.Attributes.Add("onclick", String.Format("myJsFunction('{0}')", Value.Replace("'", "\'"))) End If End With End Sub