Hi together.
I'd like to add a button in an UltraWebGrid to access a new page. How can I do this?
Many greetings
Maddi1986
Thanks for your help. But now I have another Problem: How I get the Value of the selcted Cell? Here is some code:
for (int i = 0; i < numberAppointments; i++) { UltraGridRow gridRow = new UltraGridRow(); //Date in das Datum und die Uhrzeit zerlegen string[ dateAndTime = Convert.ToString(appointments[i].AppointmentTempDate).Split(' '); string date = dateAndTime[0]; string time = dateAndTime[1]; dateCell = new UltraGridCell(); dateCell.Value = date; gridRow.Cells.Add(dateCell); timeCell = new UltraGridCell(); timeCell.Value = time; gridRow.Cells.Add(timeCell); requestCell = new UltraGridCell(); requestCell.Value = this.nodeSelected.ValuePath; gridRow.Cells.Add(requestCell); bookingCell = new UltraGridCell(); bookingCell.Value = appointments[i]; bookingCell.Text = "Termin buchen..."; gridRow.Cells.Add(bookingCell); AppointmentSuggestionView.Rows.Add(gridRow); }
//This loop fills the Grid with data an the bookingCell.Value gets an appointment
protected void AppointmentSuggestionView_ClickCellButton(object sender, CellEventArgs e) { UltraGridCell cell = e.Cell; }
//But the value of the CellEventArgsis null
How can I get the value of the selected cell?
The event handler is should be added somewhere where the event handler will always be hooked up. The handler is added when you hit your button, but hten on the postback, since the handler is not reattached, the event does not know how to get directed.
Add the handler in the form init, or add it at design time. It's not like it would be hit if you don't have buttons in your grid.
I added a button in the UltraWebGrid with the ColumnType.Button property but know I got a problem with the button event handler. Here is some code:
private void ShowAppointmentSuggestion(){
AppointmentSuggestionView.Bands[0].Columns.Add("Date", "Datum"); // AppointmentSuggestionView is the UltraWebGrid AppointmentSuggestionView.Bands[0].Columns.Add("Time", "Uhrzeit");AppointmentSuggestionView.Bands[0].Columns.Add("Request", "Anforderung");
UltraGridColumn bookingColumn = new UltraGridColumn("Booking", "Buchung", ColumnType.Button, "Booking");bookingColumn.CellButtonDisplay = CellButtonDisplay.Always;bookingColumn.Width = 145;AppointmentSuggestionView.Bands[0].Columns.Add(bookingColumn);
.... Add some data in the Grid
AppointmentSuggestionView.ClickCellButton += new ClickCellButtonEventHandler(AppointmentSuggestionView_ClickCellButton);
}
void AppointmentSuggestionView_ClickCellButton(object sender, CellEventArgs e)
{}
If I click on a button in the button column it throws a PostBack but the Method AppointmentSuggestionView_ClickCellButton will not be entered. Why not? Can somebody please help me.