Search Results

Search found 236 results on 10 pages for 'findcontrol'.

Page 5/10 | < Previous Page | 1 2 3 4 5 6 7 8 9 10  | Next Page >

  • Why is the ASP.NET Repeater.Items collection empty, when controls are on the screen?

    - by Ryan
    I have an ASP page with the following repeater: <asp:Repeater runat="server" ID="RegionRepeater" DataSourceID="SqlDataSourceRegions" EnableViewState="true"> <ItemTemplate> <tr> <td valign="top"> <b><%#Eval("description")%></b> <asp:HiddenField runat="server" ID="RegionID" Value='<%#Eval("region_id")%>'/> </td> <td> <asp:FileUpload ID="FileUpload" runat="server" Width="368px" /> </td> </tr> </ItemTemplate> </asp:Repeater> (The repeater is inside a Wizard, inside a content pane). The code behind is connected to the protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e) event. There are two items on the screen (two rows inside the table). However, when the code tries to read those items, the Items collection is empty! foreach(RepeaterItem region in RegionRepeater.Items) { // Never runs - the RegionRepeater.Items.Count = 0 FileUpload fileUpload = (FileUpload) region.FindControl("FileUpload"); String regionID = ((HiddenField)region.FindControl("RegionID")).Value; ... Why is the collection empty, when there are controls drawn on the screen? Thanks a lot for any help; this is starting to drive me nuts. (BTW: I tried adding/removing the EnableViewState="true" tag)

    Read the article

  • Help with c# event listening and usercontrols

    - by Jen
    OK so I have a page which has a listview on it. Inside the item template of the listview is a usercontrol. This usercontrol is trying to trigger an event so that the hosting page can listen to it. My problem is that the event is not being triggered as the handler is null. (ie. EditDateRateSelected is my handler and its null when debugging) protected void lnkEditDate_Click(object sender, EventArgs e) { if (EditDateRateSelected != null) EditDateRateSelected(Convert.ToDateTime(((LinkButton)frmViewRatesDate.Row.FindControl("lnkEditDate")).Text)); } On the item data bound of my listvew is where I'm adding my event handlers protected void PropertyAccommodationRates1_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { UserControls_RatesEditDate RatesViewDate1 = (UserControls_RatesEditDate)e.Item.FindControl("RatesViewDate1"); RatesViewDate1.EditDateRateSelected += new UserControls_RatesEditDate.EditDateRateEventHandler(RatesEditDate1_EditDateRateSelected); RatesViewDate1.PropertyID = (int)Master.PropertyId; if (!String.IsNullOrEmpty(Accommodations1.SelectedValue)) { RatesViewDate1.AccommodationTypeID = Convert.ToInt32(Accommodations1.SelectedValue); } else { RatesViewDate1.AccommodationTypeID = 0; } RatesViewDate1.Rate = (PropertyCMSRate)((ListViewDataItem)e.Item).DataItem; } } My event code all works fine if the control is inside the page and on page load I have the line: RatesEditDate1.EditDateRateSelected += new UserControls_RatesEditDate.EditDateRateEventHandler(RatesEditDate1_EditDateRateSelected); But obviously I need listen for events inside the listviewcontrols. Any advice would be greatly appreciated. I have tried setting EnableViewState to true for my listview but that hasn't made a difference. Is there somewhere else I'm supposed to be wiring up the control handler? Note - apologies if I've got my terminology wrong and I'm referring to delegates as handlers and such :)

    Read the article

  • “User Control” uses an incorrect event

    - by Lijo
    Hi, I am using two instances of a user control. But when I click on a button in the user control, both of the instances calls the function corresponding to the first event (AcknowledgeReceipt()) However, when I remove the first user control and clicks on the btnRequestClarification, it calls the correct method (RequestClarification()) Is there a way to correct this behavior? acknowledgeModificationPopupCtrl = (ConfirmationPopup)this.LoadControl("~/ConfirmationPopup.ascx"); plHConfirmationPopup.Controls.Add(acknowledgeModificationPopupCtrl); acknowledgeModificationPopupCtrl.ContinueClick += new EventHandler(AcknowledgeReceipt); RequiredFieldValidator reqFValidatorAcknowledge = (RequiredFieldValidator)acknowledgeModificationPopupCtrl.FindControl("reqValidatorTxt"); reqFValidatorAcknowledge.ValidationGroup = "AcknowledgeReceipt"; acknowledgeModificationPopupCtrl.ValidationGroup = "AcknowledgeReceipt"; btnAcknowledgeReceipt.Attributes.Add("onclick", "validateconfirmPopup('true','xx' ,’yyy','Note' ,'true'); return false;"); requestModificationPopupCtrl = (ConfirmationPopup)this.LoadControl("~/ConfirmationPopup.ascx"); plHConfirmationPopup.Controls.Add(requestModificationPopupCtrl); requestModificationPopupCtrl.ContinueClick += new EventHandler(RequestClarification); RequiredFieldValidator reqFValidator = (RequiredFieldValidator)requestModificationPopupCtrl.FindControl("reqValidatorTxt"); reqFValidator.ValidationGroup = "request"; requestModificationPopupCtrl.ValidationGroup = "request"; btnRequestClarification.Attributes.Add("onclick", "validateconfirmPopup('true',’kkk' ,’lll','ff' ,'true'); return false;"); Thanks Lijo

    Read the article

  • How to access values of dynamically created TextBoxes

    - by SAMIR BHOGAYTA
    If one adds controls dynamically to a page and wants to get their information after PostBack, one needs to recreate these elements after the PostBack. Let's consider the following idea: First you create some controls: for(int i=0;i TextBox objBox = new TextBox(); objBox.ID = "objBox" + i.ToString(); this.Page.Controls.Add(objBox); } After PostBack, you want to retrieve the text entered in the third TextBox. If you try this: String strText = objBox2.Text; you'll receive an exception. Why? Because the boxes have not been created again and the local variable objBox2 simply not exists. How to retrieve the Box? You'll need to recreate the box by using the code above. Then, you may try to get its value by using the following code: TextBox objBox2; objBox2 = this.Page.FindControl("objBox2") as TextBox; if(objBox2 != null) Response.Write(objBox2.Text);

    Read the article

  • Repeater vs. ListView

    - by MoezMousavi
    I do really hate repeater. I was more a GridView lover but after 3.5 be born, I prefer ListView.  The first problem with Repeater is paging. You will need to write code to handle paging. Second common problem is empty data template. Have a look at this:             if (rptMyRepeater.Items.Count < 1)             {                 if (e.Item.ItemType == ListItemType.Footer)                 {                     Label lblFooter = (Label)e.Item.FindControl("lblEmpty");                     lblFooter.Visible = true;                 }             }   I found the above code is usefull if you need to show something like "There is no record" is your data source has no records. Although the ListView has a template.   If you combine ListView with a DataPager, you will be in heaven as it is sorting the paging for you without writing code. (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datapager.aspx)     Note: You have got to bind ListView in PreRender, it doesn't work properly in PageLoad   More: http://www.4guysfromrolla.com/articles/061009-1.aspx

    Read the article

  • ASP.NET 3.5 GridView - row editing - dynamic binding to a DropDownList

    - by marc_s
    This is driving me crazy :-) I'm trying to get a ASP.NET 3.5 GridView to show a selected value as string when being displayed, and to show a DropDownList to allow me to pick a value from a given list of options when being edited. Seems simple enough? My gridview looks like this (simplified): <asp:GridView ID="grvSecondaryLocations" runat="server" DataKeyNames="ID" OnInit="grvSecondaryLocations_Init" OnRowCommand="grvSecondaryLocations_RowCommand" OnRowCancelingEdit="grvSecondaryLocations_RowCancelingEdit" OnRowDeleting="grvSecondaryLocations_RowDeleting" OnRowEditing="grvSecondaryLocations_RowEditing" OnRowUpdating="grvSecondaryLocations_RowUpdating" > <Columns> <asp:TemplateField> <ItemTemplate> <asp:Label ID="lblPbxTypeCaption" runat="server" Text='<%# Eval("PBXTypeCaptionValue") %>' /> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="ddlPBXTypeNS" runat="server" Width="200px" DataTextField="CaptionValue" DataValueField="OID" /> </EditItemTemplate> </asp:TemplateField> </asp:GridView> The grid gets displayed OK when not in editing mode - the selected PBX type shows its value in the asp:Label control. No surprise there. I load the list of values for the DropDownList into a local member called _pbxTypes in the OnLoad event of the form. I verified this - it works, the values are there. Now my challenge is: when the grid goes into editing mode for a particular row, I need to bind the list of PBX's stored in _pbxTypes. Simple enough, I thought - just grab the drop down list object in the RowEditing event and attach the list: protected void grvSecondaryLocations_RowEditing(object sender, GridViewEditEventArgs e) { grvSecondaryLocations.EditIndex = e.NewEditIndex; GridViewRow editingRow = grvSecondaryLocations.Rows[e.NewEditIndex]; DropDownList ddlPbx = (editingRow.FindControl("ddlPBXTypeNS") as DropDownList); if (ddlPbx != null) { ddlPbx.DataSource = _pbxTypes; ddlPbx.DataBind(); } .... (more stuff) } Trouble is - I never get anything back from the FindControl call - seems like the ddlPBXTypeNS doesn't exist (or can't be found). What am I missing?? Must be something really stupid.... but so far, all my Googling, reading up on GridView controls, and asking buddies hasn't helped. Who can spot the missing link? ;-) Marc

    Read the article

  • ListView not firing OnItemCommand after preventing postback

    - by nevizi
    Hi there, I have a ListView inside a FormView that, for some strange reason, doesn't fire neither the ItemInsert nor the ItemCommand event. I'm populating the ListView with a generic list. I bind the list to the ListView on the OnPreRenderComplete. <asp:ListView runat="server" ID="lvReferences" DataKeyNames="idReference" OnItemInserting="ContractReferences_Inserting" OnItemDeleting="ContractReferences_Deleting" InsertItemPosition="LastItem" OnItemCommand="ContractReferences_Command" OnItemCreated="ContractReferences_ItemDataBound"> <LayoutTemplate> <ul> <asp:PlaceHolder ID="itemPlaceholder" runat="server" /> </ul> </LayoutTemplate> <ItemTemplate> <li class="obsItem"> <a href="#"><asp:TextBox ID="valRef" runat="server" Width="5px" Enabled="false" Text='<%#Bind("idProcessRecordRef") %>' /></a> <asp:TextBox id="txtRef" runat="server" Text='<%#Bind("description") %>' /> <asp:ImageButton ID="btDelete" runat="server" CommandName="Delete" ImageUrl="~/_layouts/web.commons/Images/eliminar.png" /> </li> </ItemTemplate> <InsertItemTemplate> <li class="obsItem"> <a href="#"><asp:TextBox ID="valRef" runat="server" Width="5px" Enabled="false" /></a> <asp:TextBox id="txtRef" runat="server" /> <asp:ImageButton ID="btDetail" CausesValidation="false" OnClientClick="javascript:openPopup();return false;" runat="server" ImageUrl="~/_layouts/web.commons/Images/novo.png" /> <asp:ImageButton ID="btSaveDs" runat="server" CommmandName="Insert" CausesValidation="false" ImageUrl="~/_layouts/web.commons/Images/gravarObs.png" /> </li> </InsertItemTemplate> </asp:ListView> My ItemDataBound method is: protected void ContractReferences_ItemDataBound(object sender, ListViewItemEventArgs e) { if (!IsPostBack) { TextBox valRef = e.Item.FindControl("valRef") as TextBox; TextBox txtRef = e.Item.FindControl("txtRef") as TextBox; ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "function openPopup(){ window.open('ContractPicker.aspx?c1=" + valRef.ClientID + "&c2=" + txtRef.ClientID + "');}", true); } } So, basically, in the InsertItemTemplate I put a button that opens a LOV and populates my valRef and txtRef fields. I had to put a "return false" in order for the parent page to not postback (and I think the problem lies here...). Then, when I click in the ImageButton with the CommandName="Insert", instead of firing the ItemCommand event, it enters once again in the ItemDataBound handler. So, any ideas? Thanks!

    Read the article

  • ListView not firing OnItemCommand (nor ItemInserting) after preventing postback

    - by nevizi
    Hi there, I have a ListView inside a FormView that, for some strange reason, doesn't fire neither the ItemInsert nor the ItemCommand event. I'm populating the ListView with a generic list. I bind the list to the ListView on the OnPreRenderComplete. <asp:ListView runat="server" ID="lvReferences" DataKeyNames="idReference" OnItemInserting="ContractReferences_Inserting" OnItemDeleting="ContractReferences_Deleting" InsertItemPosition="LastItem" OnItemCommand="ContractReferences_Command" OnItemCreated="ContractReferences_ItemDataBound"> <LayoutTemplate> <ul> <asp:PlaceHolder ID="itemPlaceholder" runat="server" /> </ul> </LayoutTemplate> <ItemTemplate> <li class="obsItem"> <a href="#"><asp:TextBox ID="valRef" runat="server" Width="5px" Enabled="false" Text='<%#Bind("idProcessRecordRef") %>' /></a> <asp:TextBox id="txtRef" runat="server" Text='<%#Bind("description") %>' /> <asp:ImageButton ID="btDelete" runat="server" CommandName="Delete" ImageUrl="~/_layouts/web.commons/Images/eliminar.png" /> </li> </ItemTemplate> <InsertItemTemplate> <li class="obsItem"> <a href="#"><asp:TextBox ID="valRef" runat="server" Width="5px" Enabled="false" /></a> <asp:TextBox id="txtRef" runat="server" /> <asp:ImageButton ID="btDetail" CausesValidation="false" OnClientClick="javascript:openPopup();return false;" runat="server" ImageUrl="~/_layouts/web.commons/Images/novo.png" /> <asp:ImageButton ID="btSaveDs" runat="server" CommmandName="Insert" CausesValidation="false" ImageUrl="~/_layouts/web.commons/Images/gravarObs.png" /> </li> </InsertItemTemplate> </asp:ListView> My ItemDataBound method is: protected void ContractReferences_ItemDataBound(object sender, ListViewItemEventArgs e) { if (!IsPostBack) { TextBox valRef = e.Item.FindControl("valRef") as TextBox; TextBox txtRef = e.Item.FindControl("txtRef") as TextBox; ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "function openPopup(){ window.open('ContractPicker.aspx?c1=" + valRef.ClientID + "&c2=" + txtRef.ClientID + "');}", true); } } So, basically, in the InsertItemTemplate I put a button that opens a LOV and populates my valRef and txtRef fields. I had to put a "return false" in order for the parent page to not postback (and I think the problem lies here...). Then, when I click in the ImageButton with the CommandName="Insert", instead of firing the ItemCommand event, it enters once again in the ItemDataBound handler. So, any ideas? Thanks!

    Read the article

  • LinkButton in a DataList

    - by erasmus
    I have a datalist and in its header template I have a linkbutton.In my codebehind file I wrote as I've always written: ((LinkButton)(DataList1.FindControl("LinkButton1"))).Enabled = false; but this gives me the error: Object reference not set to an instance of an object. How can I access this linkbutton?

    Read the article

  • asp.net gridview

    - by arjun
    I have a gridview which has bound fields and a template field for checkbox.I wrote a code for deletion of records as per checking checkboxes.My problem is HtmlInputCheckBox chk; foreach(GridViewRow dr in dgvdetails.Rows) { chk = (HtmlInputCheckBox)dr.FindControl("ch"); chk.Checked = true; if (chk.Checked)/// **here checkbox is not checked even if I'm check it** { pl.id = int.Parse(chk.Value); bl.deletedgvdetails(pl); } }

    Read the article

  • How to cast a STRING to a GUID

    - by GIbboK
    Hi, I need cast a String to a Guid. I am using this code but string myUserIdContent = ((Label)row.FindControl("uxUserIdDisplayer")).Text; Guid myGuidUserId = new Guid(myUserIdContent); // PROBLEM HERE MembershipUser mySelectedUser = Membership.GetUser(myGuidUserId); I receive this error Exception Details: System.FormatException: Unrecognized Guid format. ANy other ways to do it? thanks

    Read the article

  • Iframe vs dynamically loading web user controls

    - by kevin
    I need some advice on techniques to perform page redirect in asp.net. Which one is more recommended to use in asp.net? Dynamically changed the src of the Iframe to difference aspx. Dim frame As HtmlControl = CType(Me.FindControl("frameMain"), HtmlControl) frame.Attributes("src") = "page1.aspx" Dynamically load web user controls to an asp:panel. panelMain.Controls.Clear() panelMain.Controls.Add(LoadControl("WebControl/page1.ascx")) (convert all aspx page to web user controls)

    Read the article

  • Is it possible top opt-out of INamingContainer if it's implemented by a superclass?

    - by michielvoo
    The UserControl class inherits from TemplateControl which implements INamingContainer. Since this is "only a marker interface" I was wondering if it's possible to opt-out of the behavior that this interface brings with it. I am developing a templated control based on a user control, and I want the controls inside the template to be accessible in the page without using FindControl(id).

    Read the article

  • Iframe Vs Dynamiclly load web user controls

    - by kevin
    I need some advice on technique to perform page redirect in asp.net. Which one is more recommended to use in asp.net? Dynamically changed the src of the Iframe to difference aspx. Dim frame As HtmlControl = CType(Me.FindControl("frameMain"), HtmlControl) frame.Attributes("src") = "page1.aspx" Dynamically load web user controls to an asp:panel. panelMain.Controls.Clear() panelMain.Controls.Add(LoadControl("WebControl/page1.ascx")) (convert all aspx page to web user controls)

    Read the article

  • Asp.Net GridView

    - by user329419
    I need to hide columns in GridView Then access the values of these in the GridViewSelectedIndexChanged using vb.net. When I set DataBound columns is false cant acces the values. Please help. <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BorderStyle="Outset" CellPadding="4" DataSourceID="odsA02_Tracking" Font-Size="Small" ForeColor="#333333" GridLines="Vertical" Style="border-right: #0000ff thin solid; table-layout: auto; border-top: #0000ff thin solid; font-size: x-small; border-left: #0000ff thin solid; border-bottom: #0000ff thin solid; font-family: Arial; border-collapse: separate" PageSize="30"> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <Columns> <asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="Since" HeaderText="Submit Date" ReadOnly="True" SortExpression="Since" /> <asp:BoundField DataField="Started_By" HeaderText="Submitted By" SortExpression="Started_By" /> <asp:BoundField DataField="FullName" HeaderText="Client Name" ReadOnly="True" SortExpression="FullName" /> <asp:BoundField DataField="Product_Desc" HeaderText="Product" ReadOnly="True" SortExpression="Product_Desc" /> <asp:BoundField DataField="Branch_List" HeaderText="Branch" ReadOnly="True" SortExpression="Branch_List" /> <asp:BoundField DataField="Event_AssignedID" HeaderText="Assigned To" ReadOnly="True" SortExpression="Event_AssignedID" /> <asp:BoundField DataField="DaysElapsed" HeaderText="Days Open" ReadOnly="True" SortExpression="DaysElapsed" /> <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" /> <asp:BoundField DataField="Instance_ID" HeaderText="Instance_ID" SortExpression="Instance_ID" Visible=True /> <asp:TemplateField Visible=False> <ItemTemplate> <asp:HiddenField ID=hdnSeqID Value='<%#Eval("Seq_ID") %>' runat=server/> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="FormCode" Visible=false> <ItemTemplate> <asp:HiddenField ID=hdnFormCode Value='<%#Eval("Form_Code") %>' runat=server/> </ItemTemplate> </asp:TemplateField> </Columns> Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged Dim Instance_ID As String Dim Seq_ID As String Dim Form_Code As String Dim PARMS As String Dim DestinationURL As String Dim DestinationParms As String 'fill text box's with values from selected row ' store values from selected row Dim seqID As String = CType(GridView1.SelectedRow.FindControl("hdnSeqID"), HiddenField).Value Dim formCode As String = CType(GridView1.SelectedRow.FindControl("hdnFormCode"), HiddenField).Value End Sub

    Read the article

  • Can a storyboard access the UserControl that it resides in?

    - by Jeremy
    I have a usercontrol, and I want a storyboard inside the user control to fade the user control out. Using Expression Blend, I can create the storyboard and cause it to fade the user control out, but when I run the silverlight application I get an error on FindControl stating that it can't find the control. I'm guessing the find control only searches the children of the parent, but does not look at the parent itself. Is there any way around this?

    Read the article

  • Set item.selected in ASP.NET Menu Control

    - by BillB
    ASP.NET newbie here. When on a page I'd like to set the corresponding menu item to selected. My approach is this: On Home.aspx.cs: Menu menu = (Menu)Master.FindControl("Menu1"); if (menu.Items.Count > 0) { menu.FindItem("Home").Selected = true; } Trouble is, menu.item.count == 0. My menu is bound to a sitemap, if that matters. Thanks, Bill

    Read the article

  • Find Control In Datalist

    - by KareemSaad
    When I tried To Find Control n data List As I Mentioned Below Error(Object reference not set to an instance of an object. I cannot know protected void dlCategory_ItemDataBound(object sender, DataListItemEventArgs e) { Label Lb = (Label)e.Item.FindControl("LblCat"); Lb.ForeColor = System.Drawing.Color.Red; } ' onitemcreated="dlSubCategory_ItemCreated" onitemdatabound="dlSubCategory_ItemDataBound" ' class="buttn_txt" '

    Read the article

  • give control in datalist color

    - by KareemSaad
    I had datalist as menu that display categories and subs and I want to give red color or css for the selected item(category or sub) I tried but I had a problem This is my code private Label Lb; protected void Page_Load(object sender, EventArgs e) { } protected void dlCategory_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Lb = (Label)e.Item.FindControl("LblCat"); } } protected void dlCategory_SelectedIndexChanged(object sender, EventArgs e) { Lb.ForeColor = System.Drawing.Color.Red; } }

    Read the article

  • how to implement a counter in label which decrements every time page is loaded in asp.net(vb)?

    - by Parth
    how to implement a counter in label which decrements every time page is loaded in asp.net(vb)? It would be better if that counter value is accessed from and updated into database.. I've tried this on buttonclick but the value is reset automatically to intial value everytime as the button is insert and page is reloaded Protected Sub InsertButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim entries As Label = FindControl("label1") entries.Text = entries.Text - 1 End Sub

    Read the article

  • asp.net web forms best practice to retrieve dynamic server control values

    - by Andrew Florko
    I populate web form with dynamic list of exams from database. I want user to enter examination marks for each exam. There is list of exam titles and textbox near each title. I create list with repeater control: <asp:Repeater ID="rptExams" runat="server" onitemdatabound="rptExams_ItemDataBound" > <ItemTemplate> <tr> <td> <asp:Literal runat="server" ID="ltTitle"/> </td> <td> <asp:HiddenField runat="server" ID="hfId"/> <asp:Textbox runat="server" ID="tbMark"/> </td> </tr> </ItemTemplate> </asp:Repeater> And bind data to repeater on page_init: class Exam { public int Id { get; set;} public string Title { get; set;} } ... // this list is retrieved from database actually Exam[] Exams = new Exam[] { new Exam { Id = 1, Title = "Math"}, new Exam { Id = 2, Title = "History"} }; ... protected void Page_Init(object sender, EventArgs e) { rptExams.DataSource = Exams; rptExams.DataBind(); } So far so good. Then I have to retrieve data on postback. I have two ways but both of them looks ugly. Idea is to store dynamically created databounded controls on ItemDataBoundEvent in Page_Init stage, and process their values in Page_Load stage. It looks like this: private Dictionary<HiddenField, TextBox> Id2Mark = new Dictionary<HiddenField, TextBox>(); protected void rptExams_ItemDataBound(object sender, RepeaterItemEventArgs e) { ... if (IsPostBack) { var tbMark = (TextBox)e.Item.FindControl("tbMark"); var hfId = (HiddenField)e.Item.FindControl("hfId"); // store dynamically created controls Id2Mark.Add(hfId, tbMark); } ... } protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { foreach (var pair in Id2Mark) { int examId = Int32.Parse(pair.Key.Value); string mark = pair.Value.Text; // PROCESS } ... I'm completely sure there is a better way to retrieve data from dynamically created controls. Thank you in advance!

    Read the article

  • Alert on gridview edit based on permission

    - by Vicky
    I have a gridview with edit option at the start of the row. Also I maintain a seperate table called Permission where I maintain user permissions. I have three different types of permissions like Admin, Leads, Programmers. These all three will have access to the gridview. Except admin if anyone tries to edit the gridview on clicking the edit option, I need to give an alert like This row has important validation and make sure you make proper changes. When I edit, the action with happen on table called Application. The table has a column called Comments. Also the alert should happen only when they try to edit rows where the Comments column have these values in them. ManLog datas Funding Approved Exported Applications My try so far. public bool IsApplicationUser(string userName) { return CheckUser(userName); } public static bool CheckUser(string userName) { string CS = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(); DataTable dt = new DataTable(); using (SqlConnection connection = new SqlConnection(CS)) { SqlCommand command = new SqlCommand(); command.Connection = connection; string strquery = "select * from Permissions where AppCode='Nest' and UserID = '" + userName + "'"; SqlCommand cmd = new SqlCommand(strquery, connection); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); } if (dt.Rows.Count >= 1) return true; else return true; } protected void Details_RowCommand(object sender, GridViewCommandEventArgs e) { string currentUser = HttpContext.Current.Request.LogonUserIdentity.Name; string str = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(); string[] words = currentUser.Split('\\'); currentUser = words[1]; bool appuser = IsApplicationUser(currentUser); if (appuser) { DataSet ds = new DataSet(); using (SqlConnection connection = new SqlConnection(str)) { SqlCommand command = new SqlCommand(); command.Connection = connection; string strquery = "select Role_Cd from User_Role where AppCode='PM' and UserID = '" + currentUser + "'"; SqlCommand cmd = new SqlCommand(strquery, connection); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); } if (e.CommandName.Equals("Edit") && ds.Tables[0].Rows[0]["Role_Cd"].ToString().Trim() != "ADMIN") { int index = Convert.ToInt32(e.CommandArgument); GridView gvCurrentGrid = (GridView)sender; GridViewRow row = gvCurrentGrid.Rows[index]; string strID = ((Label)row.FindControl("lblID")).Text; string strAppName = ((Label)row.FindControl("lblAppName")).Text; Response.Redirect("AddApplication.aspx?ID=" + strID + "&AppName=" + strAppName + "&Edit=True"); } } } Kindly let me know if I need to add something. Thanks for any suggestions.

    Read the article

  • find controls from dynamically created table

    - by tina
    hi, i wrote a function to create dynamic table in code behind on selectedindexchanged of checkbox, that is when user will check 2 checkboxex 2 tables will be generated with textboxes, Then on button click i want insert values of these textboxes in database, for that i want to find textbox using findcontrol,but i could not find it, So i called same function of table creation on page load, but then it shows error that textbox is having duplicate id Plz tell me solution for this. thanks

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10  | Next Page >