How to take controls inside a .ascx inside the edititemtemplate of a datalist

I've read a lot of posts but I've not found the solution.

I want to take controls inside a .ascx that is located  inside the edititemtemplate of a datalist

updater.ascx file


<table width="100%">
    <tr>
        <td class="encabezado" colspan="2">
            Modifica la noticia</td>
    </tr>
    <tr>
        <td width="25%">
            Título:</td>
        <td>
            <asp:TextBox ID="tb_Titulo" runat="server" Width="335px"></asp:TextBox>
        </td>
    </tr>
</table>


file.aspx

<asp:DataList ID="DataList1" runat="server" DataSourceID="ods_Noticia" OnDeleteCommand="DataList1_DeleteCommand" OnEditCommand="DataList1_EditCommand" OnCancelCommand="DataList1_CancelCommand" OnUpdateCommand="DataList1_UpdateCommand" OnItemDataBound="DataList1_ItemDataBound">
    <ItemTemplate>
       ....
    </ItemTemplate>
    <EditItemTemplate>
        <uc1:Update Id="Update1" runat="server"  Titulo='<%# Eval("Titulo") %>'   />         
    </EditItemTemplate>
</asp:DataList>



Since now everything works well, I have the correct properties for updater.ascx, etc.
The only problem is that when I fire the updatecommand of the datalist, I want to take the value of tb_Titulo (inside the updater.ascx), and I don't know how!!
Since now I have, but nothing happens Smile [:)]:

    protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
    {
       // other variables

        Control ctr = (Control)e.Item.FindControl("Update1");
 
       //update features

        DataList1.EditItemIndex = -1;
        DataList1.DataBind();
    }


Any help!!

Thanks


subgurim.net: blog de ASP.NET 2.0 con C# en castellano
es-asp.net: el portal de ASP.NET en castellano
0
subgurim
9/14/2005 10:48:56 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
672 Views

Similar Articles

[PageSpeed] 45
Get it on Google Play
Get it on Apple App Store

Define a get property inside the updater.ascx (similar to what you did for Titulo) and the return the value. You can use that value on the Update command: ctr.Titulo
0
aspdotnetv2
9/14/2005 1:39:07 PM
OK that's right but my really problem was that I didn´t know that a class Updater were automatically created

Instead of doing
Control ctr = (Control)e.Item.FindControl("Update1");

Now I do
Updater ctr = (Updater )e.Item.FindControl("Update1");


And then the problem is easily solved.

Thanks!!


subgurim.net: blog de ASP.NET 2.0 con C# en castellano
es-asp.net: el portal de ASP.NET en castellano
0
subgurim
9/14/2005 1:56:13 PM
Reply:

Similar Artilces:

How to find a Control inside a Datalist(DataList also inside in a DataList)
I search the forum but i couldn't find the solution. Most examples written in VB.NET. I have Datalist(DataList1) showing some data and inside DataList1 there is one more DataList(DataList2). Inside DataList2 there are checkboxes. Outside of DataList1 there is Button(Button1). What i want is, when i click Button1, it wil find the CheckBoxes which is checked , and gets their Text property and assign it to a string or something. Will be very appreciated for help. Waiting for answers. I am using VS.2005 and coding with C#.  Here is a example schema: #DataList1######################...

DataList control inside another dataList control...
one of my aspx page requires to display data from a master table and show another set of data inside each row from a child table i tried by putting a datalist another datalist but could not make it i get errors :: CODE :: Dim ObjChildRental As DataList() Dim StrRentalSql As String = "select rentalid,startdate,enddate,amount,lookup.lookupname as curr from rental inner join lookup on lookup.lookupid=rental.currencyid where rental.propertyid=1" ObjChildRental = DLPropertyMaster.FindControl("dlpropertymaster:_ctl0:dlrental") M.BindDataList(ObjChild...

FileUpload control inside UpdatePanel inside user control inside popup
Hi,     The Asp.Net File Upload control is not working inside update panel. Acutally i have put the FileUpload control inside User Control again inside update panel. Since the update panel does async postback. The posted file is null in the server side. When i do full page level post back it works. but i have to put it inside update panel. How to do it? Becuase the FileUpload control should be in Ajax Model Popup Extender where i have to put update panel to avoid closing of popup after fullpostback. Since the ajax model popup extender is getting closed after full post b...

Controls inside Datalist control
When I droped a CustomValidator on a web form and double click on the control, it brings me to the code withPrivate Sub CustomValidator1_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate End SubBut if I droped a CustomValidator in a DataList control, I couldn't see the control.  I tried Handles DataList.CustomValidator1.ServerValidate, but it didn't work.  How do I make the CustomValidator in a DataList work?  Thanks.Dan-Yeung Hi, you cannot assign event handler into a co...

How to access control inside DataList control?
I have a dataList control that is used to create thumbnails of my images. Inside this dataList I have an Image, HyperLink, and CheckBox controls. I want to access the checkBox controls during run time when the user click on the Delete button. In the btnDelete method, I want to check if the chbDelete control is checked. If it is checked, grab the Text property (which is the file path and file name) and then delete the file off of the image folder. So here's my code.  1 CheckBox chbImageFile = (CheckBox)dtlBrowseImage.FindControl("chbDelete"); 2 3 if (ch...

Binding controls inside the datalist control
Hi All, I am trying to render flash movie files inside a data list contol which is bounded to the database. What i wanna to do is to get the value from the data list as itme index and then render the falsh movie file accordingly. I have a fucntion for that render for flash file. My problem is that i want to make a call to that render function from my data list. To hold that flash file i am using a place holder in the web form. i come to a solution where i am using objF = (PlaceHolder)e.Item.FindControl("FlashObj"); Render(objF); its working but i am not convienced with that. is the...

How to access control inside DataList control? #2
Since DataList does not seem to have mode, I can't find a way to access the Image control inside of DataList control.I have tried this:Image imgStaffPic = (Image)DataList1.FindControl("imgStaffImage");imgStaffPic.Visible = false; The error was: Object reference not set to an instance of an object.  So any help is appreciated. Hello, Have you tried using the ItemDataBound Event? Here is a sample I put together for you.  protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType...

Setting DropDownList controls inside a Datalist control
I have DropDownList controls inside a Datalist control.   I would be grateful if someone could tell me how to enable or disable a ListItem control accordingly with the  data contained in a DataTable.   Here are the ListItem controls:       <asp:ListItem Value="blue" >Blue</asp:ListItem>     <asp:ListItem Value="red" >Red</asp:ListItem>     <asp:ListItem Value="black" >Black</asp:ListItem>     <asp:ListItem Value="white" >white</asp:ListItem>   For i...

another Control inside a Datalist Control question
hi, after a few research, i was informed that i can't simply access a control inside a datalist/repeater-style control because this control inside the datalist control, during run-time, will be "recreated" many times, hence they will have different ID's.  now, i have this simple web site. it contains a "blog" feature, where logged-in users may post messages. i do this by creating a separate "post new" message, that contains a few textboxes (subject, message, etc), then when i click the post button, it performs an SQL INSERT to my sql database. i then take the user back to t...

How can I dynamically access control inside DataList ItemDataBound event when SeparatorTemplate is used for DataList control?
Hello, Usually I can dynamically access control (Label in this case) inside DataList ItemDataBound event using this code: Dim Label1 As Label = e.Item.FindControl("Label1")Label1.Text = "sample text" But when custom SeparatorTemplate is used for DataList control, then this code no longer works and produces this error: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code...

Problem with TreeView control inside tabs structure and inside MultiView control
I have web parts inside 2 different 'tab' stuctueres.  In the first one I am using a MultiView control to simulate tabs.  In the second case I'm using some basic javascript and and divs to create my tab structure.  In either case, however, the web parts as well as other Atlas enabled controls (controls within an UpdatePanel) do not seem to work.  The web parts do not even render.  And my control in another tab, which is basically a TreeView wrapped in an UpdatePanel, does not function.  It renders but the navigation stops working.  If anybody has ru...

User Control Inside a Modal Pop Up
Hello, I am a beginner with AJAX and need some help. I have a user user control that I want to place in a Modal Pop up, but I am running into some issues.  The user control is used for doing some seaching of database records. After the use selects a record, they choose from one of three radio buttons and then hit a submit button. This submit button has logic tied to it that needs to be performed before closing the modal pop up. I want to make this button (btnDoLogic) that is inside the User Control, the button that is tied to the...

Getting the control id of a control inside gridview control
 uhmm.. a little bit confusing regarding my subject because i dont know how to say it...by the way my problem is how can i get the id of a control (e.g. textbox) inside the gridview... and the textbox is in the templatefield... is there any way i can get its id??  hoping i could get a reply as soon as possible... Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) What do you want's to do by getting the id of the Text box? Do you want's to find particular Textbox with certain id ? Kamran ShahidSr. Software Engineer(MCP,MCAD.net,MC...

How to get control inside datalist web server control
hi, I am using <asp:hyperlink id="hyper"> control in one datalist control, i want to bind url at the time of itemdatabound event so please suggest me how to get this controls handle   See if this works (in C#): protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { HyperLink hl = e.Item.FindControl("hyper") as HyperLink; hl.NavigateUrl = "whatever"; }  ...

Web resources about - How to take controls inside a .ascx inside the edititemtemplate of a datalist - asp.net.presentation-controls

Resources last updated: 1/22/2016 5:41:42 PM