Passing parameters in an ASP.Net DetailsView OnClick event handler

anyi-

New Member
Is it possible to send a parameter in an ASP.Net OnClick enent handler to a code-behind file?In a DetailsView we have this markup for each day of the week for the Edit template and on top of that another bunch of coding for the insert template:\[code\]<EditItemTemplate> <asp:ImageButton ID="ImageButtonEditDayOfWeekMonday" runat="server" ImageUrl='<%# getCheckboxImageToDisplay(Eval("DayOfWeekMonday"))%>' Height="15" Width="15" OnClick="ImageButtonEditDayOfWeekMonday_Click" CausesValidation="False"> </asp:ImageButton></EditItemTemplate>\[/code\]The handler in the code-behind file:\[code\]Protected Sub ImageButtonEditDayOfWeekTuesday_Click(sender As Object, e As ImageClickEventArgs) Dim imgTheImageButton As New ImageButton imgTheImageButton = DetailsView.FindControl("ImageButtonEditDayOfWeekTuesday") If imgTheImageButton.ImageUrl = "../../Images/checked.png" = True Then imgTheImageButton.ImageUrl = "../../Images/unchecked.png" LabelCheckBoxTuesday.Text = False Else imgTheImageButton.ImageUrl = "../../Images/checked.png" LabelCheckBoxTuesday.Text = True End IfEnd Sub\[/code\]That will amount to a lot of coding. Is it possible to do create a single handler and call it like this?\[code\]OnClick="ImageButtonDayOfWeek_Click("Monday", "Edit")\[/code\]The only difference between all the handlers is:\[code\]imgTheImageButton = DetailsView.FindControl("ImageButtonEditDayOfWeekTuesday")\[/code\]It would be nice to just use a bunch of if statements inside a single handler and use the appropriate "ID" to place in DetailsView.FindControl.
 
Back
Top