class DropDownListTemplate : IBindableTemplate<br> {<br> string dataField = null;<br> bool enabled;<br> DropDownList ddl = null;<br><br> public DropDownListTemplate(string dataField, bool enabled)<br> {<br> this.dataField = dataField;<br> this.enabled = enabled;<br> }<br><br> void ITemplate.InstantiateIn(Control container)<br> {<br> ddl = new DropDownList();<br> ddl.Enabled = enabled;<br> ddl.DataBinding += ddl_DataBinding;<br> container.Controls.Add(ddl);<br> }<br><br> void ddl_DataBinding(object sender, EventArgs e)<br> {<br> ddl = (DropDownList)sender;<br> ddl.ID = dataField;<br> GridEditFormItem bidingContainer = ddl.NamingContainer as GridEditFormItem;<br> string value = ((DataRowView)bidingContainer.DataItem)[dataField].ToString();<br><br> ddl.Items.Add(value);<br><br> }<br> <br><br> IOrderedDictionary IBindableTemplate.ExtractValues(Control container)<br> {<br> OrderedDictionary dick = new OrderedDictionary();<br> dick.Add(dataField, ddl.SelectedValue.ToString());<br> return dick;<br> }<br> }
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="lookupButton"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="orderPanel" LoadingPanelID="RadAjaxLoadingPanel1" /> <telerik:AjaxUpdatedControl ControlID="errorLabel"/> <telerik:AjaxUpdatedControl ControlID="countPanel" LoadingPanelID="RadAjaxLoadingPanel1" /> <telerik:AjaxUpdatedControl ControlID="orderCount" LoadingPanelID="RadAjaxLoadingPanel1" /> <telerik:AjaxUpdatedControl ControlID="amountPanel" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="inputButton"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="amountPanel" LoadingPanelID="RadAjaxLoadingPanel1" /> <telerik:AjaxUpdatedControl ControlID="amountList" LoadingPanelID="RadAjaxLoadingPanel1" /> <telerik:AjaxUpdatedControl ControlID="errorLabel"/> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="printButton"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="errorLabel"/> <telerik:AjaxUpdatedControl ControlID="printButton" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="WebBlue" /> <asp:Panel ID="orderPanel" runat="server" DefaultButton="lookupButton"> <fieldset> <legend>Order Information</legend> <table> <tr> <td align="left"><telerik:RadNumericTextBox ID="orderNum" Width="150px" runat="server" MaxLength="6" NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator="" DataType="Int32"></telerik:RadNumericTextBox></td> <td align="left"><asp:Button ID="lookupButton" runat="server" Text="Look Up Order" OnClick="LookupButton_Click" /></td> </tr> <tr> <td align="left"><asp:Label ID="orderSalesText" runat="server" Font-Size="Small" Font-Bold="true" Text="Money Order Amount: "></asp:Label></td> <td align="left"><asp:Label ID="orderSalesValue" runat="server" Font-Size="Small" Font-Bold="true"></asp:Label></td> </tr> <tr> <td align="left"><asp:Label ID="orderFeesText" runat="server" Font-Size="Small" Font-Bold="true" Text="Money Order Fees: "></asp:Label></td> <td align="left"><asp:Label ID="orderFeesValue" runat="server" Font-Size="Small" Font-Bold="true"></asp:Label></td> </tr> </table> </fieldset> </asp:Panel> <br /> <br /> <asp:Panel ID="logPanel" runat="server"> </asp:Panel> <asp:Panel ID="countPanel" runat="server" DefaultButton="inputButton" Visible="false"> <fieldset> <legend>Total Money Orders</legend> <table> <tr> <td align="left"><telerik:RadNumericTextBox ID="orderCount" Width="150px" runat="server" MaxLength="2" NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator="" DataType="Int32"></telerik:RadNumericTextBox></td> <td align="left"><asp:Button ID="inputButton" runat="server" Text="Enter Count" OnClick="InputButton_Click" /></td> </tr> </table> </fieldset> </asp:Panel> <br /> <br /> <asp:Panel ID="amountPanel" runat="server" Visible="false" DefaultButton="printButton"> <telerik:RadListView ID="amountList" runat="server" ItemPlaceholderID="amountPlaceHolder"> <LayoutTemplate> <fieldset> <legend>Money Order Amounts</legend> <asp:Panel ID="amountPlaceHolder" runat="server"></asp:Panel> </fieldset> </LayoutTemplate> <ItemTemplate> <center> <table> <tr> <td align="right"><asp:Label ID="amountLabel" runat="server" Text="<%# Container.DataItem.ToString() %>" Font-Bold="true" Font-Size="Small"></asp:Label></td> <td align="left"><telerik:RadNumericTextBox ID="amountBox" Width="150px" runat="server" NumberFormat-DecimalDigits="2" DataType="double"></telerik:RadNumericTextBox></td> </tr> </table> </center> </ItemTemplate> </telerik:RadListView> <br /> <br /> <center> <asp:CheckBox ID="suspFlag" runat="server" /><asp:Label runat="server" ID="suspText" Text="This order is suspicious" Font-Bold="true" Font-Size="Small"></asp:Label> <br /> <asp:Button ID="printButton" runat="server" Text="Print Money Orders" OnClick="PrintButton_Click" /> </center> </asp:Panel>public partial class MoneyOrder_Create : System.Web.UI.Page{ ACROrder order = ACRFunctions.Order; int moneyOrderCount = ACRFunctions.OrderCount; protected void Page_Load(object sender, EventArgs e) { ((AppMasterPage)Master).verNum = "3.5"; ((AppMasterPage)Master).visibleHome = true; ((AppMasterPage)Master).AppName = "Money Order Creation"; ((AppMasterPage)Master).visibleBreadCrum = true; ((AppMasterPage)Master).subMenuName = navLastMenu.GetMenuLineApps(navLastMenu.GetPreviousMenuID(Convert.ToInt32(Session["SessionMenuID"]))); if (Request.QueryString["error"] != null) errorLabel.Text = Request.QueryString["error"]; } protected void LookupButton_Click(object sender, EventArgs e) { order = ACRFunctions.GetACROrder(Convert.ToInt32(orderNum.Text), true); if (order.Order_No == -1) SetLookupText("Cannot Find Order in ACR", "", ""); else { if (ACRFunctions.OrderIsMoneyOrder(order)) { if (!ACRFunctions.OrderIsUsed(order)) { SetLookupText("", ACRFunctions.GetMoneyOrderSum(order).ToString("C"), ACRFunctions.GetMoneyOrderFees(order).ToString("C")); SetFocus(orderCount); ACRFunctions.Order = order; countPanel.Visible = true; } else SetLookupText("This ACR Order has already been used to print money orders", "", ""); } else SetLookupText("Not a Valid Money Order Transaction", "", ""); } } public void SetLookupText(string errorText, string salesText, string feesText) { errorLabel.Text = errorText; orderSalesValue.Text = salesText; orderFeesValue.Text = feesText; if (salesText == "") { countPanel.Visible = false; amountPanel.Visible = false; } } protected void InputButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(orderCount.Text)) { errorLabel.Text = "You Must Enter a Count"; return; } else { moneyOrderCount = Convert.ToInt32(orderCount.Text); if (moneyOrderCount <= 0) { errorLabel.Text = "You Must Enter a Positive Number"; amountList.DataSource = null; return; } errorLabel.Text = ""; amountPanel.Visible = true; ArrayList list = new ArrayList(); for (int i = 0; i < moneyOrderCount; i++) { list.Add("Amount " + (i + 1) + ": "); } amountList.DataSource = list; ACRFunctions.OrderCount = moneyOrderCount; } } protected void PrintButton_Click(object sender, EventArgs e) { List<decimal> amounts = new List<decimal>(); foreach (var item in amountList.Items) { if (string.IsNullOrEmpty(((item.FindControl("amountBox") as RadNumericTextBox).Text))) { errorLabel.Text = "You must enter an amount for each money order. Change the count if you entered too many."; return; } else if (Convert.ToDecimal((item.FindControl("amountBox") as RadNumericTextBox).Text) <= 0) { errorLabel.Text = "Money Order Amounts Must Be Greater than Zero."; return; } else amounts.Add(Convert.ToDecimal((item.FindControl("amountBox") as RadNumericTextBox).Text)); } Printer printer = new Printer(); string error = printer.PrintMoneyOrders(amounts, ACRFunctions.Order, suspFlag.Checked, Session["SessionUserNum"].ToString(), Request.ServerVariables["REMOTE_ADDR"]); if (!string.IsNullOrEmpty(error)) errorLabel.Text = error; else errorLabel.Text = "Print Successful"; }}Hello
I need to set the ID of a repeated button in a RADGrid and then get that ID in the VB code on the server side when it is clicked.
Hers what I’m looking to do...
1) Using a RADGrid I want a Button in one of the columns (Got it/Can do)
2) When that button is clicked it calls a set of code (function/sub) server side VB
- I want to give each button a defend ID using the record ID in dataset the data set that’s building out the table for the grid.
- The code that is called will be the same no matter what button in the list is clicked
- The code it calls can know/get what button ID was clicked so that it may use the ID to drill in to the DB.
(I know how to do the DB work, just need the Button ID that was clicked, sever side VB)
-Problems/help??
- I can’t see how to set the ID via the RADGrid designer
-- I do see how to for "tool tip" and the like but not the button ID (not the button text)
- Where do I set it to call a sub or function that I have in the VB code page?
- What code would go in go in the Sub:
Sub GridButtonEdit()
BtnClkd = Get.GridButtonEdit.ID
End Sub
--- Something like that???? ---
If it’s not possible to set the Button ID (as I see it’s some random long string now) then is there something I could set that I could then get in the code that it calls?
Thanks for the help!
Shane