I have the following implementation:
A repeater if I can see (List of machines) and a nested repeater (List of WindowsServices inside each machine). For each Windows service I can do an action using a button. However, to get this action I want to know which machine and WindowsService are worried.
This is my code:.
protected void Page_Init (object sender, EventArgs e) {RptMachine.ItemDataBound + = new repeater Aitemaventhandlr (rptMachine_ItemDataBound); } Secure Zero Page_Load (Object Sender, EventArgs E) {// Binding Binding Machine Ripper rptMachine.DataSource = _monitoringService.Machines; RptMachine.DataBind (); } Protected void RptMachine_ItemDataBound (object sender, repeater items Event ARG e) {if (e. ITM. Itam type == list Itam Taipkitm} e. Items. Aitam type == list Itam Taip.aleneting item) {repeater nested Repiyetr = (Repeater) e.Item.FindControl ("rptWindowsService"); Nested repetor.datasource = ((iMacin) e.itimate.datitum). Windows Services; NestedRepeater.DataBind (); Button BTNActionInner = Faucet; // nested repeater RepeaterItem for foreach (nestedRepeater.Items re) bind action button inside {if ((Button) ri.FindControl ( "btnAction")! = NULL) {btnActionInner = (Button) ri.FindControl ( "btnAction") ; BtnActionInner.CommandName = "ActionStat"; BtnActionInner.CommandArgument = strWindowsService; }}}} Protected void rptWindowsService_ItemCommand (object source, repeater Command Aventaarjis e) {// stop specific task / run to serve the windows if (e.CommandName == "Akshnstet") {if (((button (e. CommandSource))) Text.Equals ( "off")) {} else if (((button) (e.CommandSource)). Text.Equals ( "run")) {}}}}}
So basically what I need to know (inside
rptWindowsService_ItemCommand
) is the pair that is concerned with the operation.What is the best way to do this?
Do not hesitate to ask for more clarification!
Thank you
your code for "current" machine / window service on DataboundItem Set a temporary asset in, then just bind them. Code Back:
& lt; Asp: repeater data source = "& lt;% #MistyList%>" OnItemDataBound = "Machine_DataBound" & gt; & Lt; Asp: Repeater Data Source = "& lt;% # (Machine container .datetime). Services% & gt;" & Gt; & Lt; ASP: Button ID = "whatever" text = '& lt;% # string.format ("kill service ({0}. {1})", currentmachine name, (service container.diet). Name) ; % & Gt; '/ & Gt; & Lt; / ASP: Repeater & gt; & Lt; / ASP: Repeater & gt;
Getting Current Machin {Private Machine}; Set; } Public Zero Machine / DataBound (Object Sender, Repeater Item Event ARG E) {CurrentMachine = e.Item as Machine; }
Comments
Post a Comment