Control-Access in Template-Column ?

Hi!

I createted a Template-Column in a DataGrid with a Dropdownlis set as edititem-control
and bound it to values of a table on a MS-SQL-Server.
So far so good - calling the edit command on runtime is working properly.
The Items are correct i can select one and it will be written down to the database
*but *
I want to initialize the dropdownlist when calling th edit-command - the selecteditem
should be a default-value. How can I achieve this. The Control is only exiting @ runtime ...
Tryed to do sthg. like this:
--
Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
Dim ddl As DropDownList
ddl = CType(e.Item.Cells(6).Controls(0), DropDownList)
ddl.SelectedIndex = 4
call display_data()
End Sub
--
Can anyone help me
Paul
0
jnx
9/1/2004 10:02:44 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
478 Views

Similar Articles

[PageSpeed] 0

You need to set the SelectedIndex during the ItemDataBound event of the grid. Check if Item is in Edit mode (if e.Item.ItemType=EditItem....), hook up to the control and set its selected index using the DRopDownList.Indexof(DropDownList.Items.FindByValue(......)


Hope this helps
Bug [MCSD]
0
Bug_Bugger
9/1/2004 12:58:06 PM
Reply:

Similar Artilces:

Serverside Template Control
I've created a template control what I am running into difficults is during the Page_Load event on my web page I cannot access the child controls in the two possible templates. What I would like to be able to do is set the value or make some changes to the control at runtime but I have not been successful in gaining code access to the control, for example the TEXTBOX1 control in the EditTemplate template.     Does anyone know a good way to preform this task, let alone if I am even using the correct event Example of HTML Render  <aspSample:TextLabe...

How to access a child control in a templated control?
I am not sure how to access a child control that I addes to a templated control. For example: I drag a Login Control (ID: "Login1") into page in VisualStudio web developer, I can click on it and from the upper right of that control now in my desinger I can choose "convert to template".  Now I can drop in my own control to be added to the Login Control.  Let say I drag over a DropDownList control (ID: "DropDownList1") and place it at the bottom within the Login Control. At run time I might expect to access the my DropDownList control with somethin...

Accessing Child Controls of a Template Server Control
I've created a templated control that has a property called ContentTemplate which is of type ITemplate.  The control works great with the exception of I now have to interact with the child controls via the FindControl method. Markup: <test:MyControl ID="testControl" runat="server"> <ContentTemplate> <asp:Label ID="testLabel" runat="server" /> </ContentTemplate> </test:MyControl>    In order to interact with the child label, testLabel, I now need to do something like this:Dim lbl As La...

Access controls in Wizard control header template.
Is this possible?Web dev - spending forever achieving nothing. hi, suppose the control in the header template is a DDL with Id DropDownList1 access it this way DropDownList dp = (DropDownList)Wizard1.FindControl("headerContainer$DropDownList1");        Response.Write(dp.SelectedValue); hope it helpsJessica CaoSincerely,Microsoft Online Community Support“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community ...

Accessing controls inside User control template
Hi, I need to create a user control with one template. That template needs to be like View in MultiView or Wizzard control or Panel. It means, that controls, which are inside should be visible to the page. It will be created just once per control. I need to be able to write :  TextBox1.Text = "Hello world" not : (MyUserControl1.Controls.FindControl("TextBox1") as TextBox).Text = "Hello world" Thanks, radco  If this is a answer to your problem, mark it as answer in right upper corner. It helps other who read your article to known that...

How to access page control (editor control) from user control?
Hi, I want to do something, but I don't know if it's even possible. I'm trying to make a simple application to edit my website. I have a page called editPage.aspx which contains an editor control. (cuteEditor from cutesoft) I also have a Treeview that dynamically populates my website structure. I placed this treeview in a custom control (populateTreeView.ascx) and placed it on the editPage.aspx page. When you click on a html file in the treeview (inside the custom control) I check if the file exists. If it does exists I send it to a class which retrieves the editable region within this ...

How do I access control on edit item template in DataView control?
I have a DataView control. I have a Template Field named MyNewTemplateField and in it's Edit Items Template I have a text box called "txtMyTextBox", which I want to do something with the data typed in, and then take that result and put it in the Access database.  Protected Sub DataView1_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewCommandEventArgs) Handles dvAcct.ItemCommand Select Case e.CommandName Case "Edit" Dim txtTheText As New TextBox txtTheText = DataView1.FindControl("txtMyTextBox"...

A standardized method to access to controls that are within a Templated Control.
Hello, As all of us we know, lots of controls are of the type of "templated controls". This controls can hold, in any of their templated sets other controls. The problem arise when we try to access to the aforementioned controls in the code-behind/beside (I don't know yet how to name this model) file. Could be, in anyway, implemented a standardized way to access to those controls? Apologize my ignorance in this topic. Greetings.VB .Net Coder - Apologize my C# nescienceBest Regards. Hello. What are you trying to do? you can always use FindControl as your last resort, but maybe t...

Accessing controls in template column with JavaScript
Hi Guys & Gals, Is it possible to access controls (e.g. a CheckBox) within a template column in a datagrid with JavaScript? I would like to count the number of rows in my datagrid with checked boxes on the client side, i.e. without a post back. Anybody know how to do this? I would also like to do a hotmail style select all on the client side. Is this possible with a datagrid? Thanks in advance! Peter Yes you sure can, there are tons of ways of doing that, but here is one that I think is easy enough: (I know there are many ways to generate the script but I wanted to le...

Accessing controls in template column with JavaScript
Hello List, Is it possible to access Button control within a template column in a datagrid with JavaScript? Thanks in advance! Peter...

How to access a template column in a datagrid control
I have a DataGrid control on a web form with a template column. How can I access the dropdownlist column "ddlusertype" from my c# code? I need to bind it with a DataTable. Please help, thanks! Here is my code <Columns> <asp:BoundColumn DataField="rolName" HeaderText="User Type"></asp:BoundColumn> <asp:BoundColumn DataField="rolDescription" HeaderText="Description"></asp:BoundColumn> <asp:BoundColumn DataField="gtyAbbr" HeaderText="Client Type"></asp:B...

How to access a user control from another user control in a Wizard control
My page has a wizard control and each step is a user control.  I could find the value of a control in step1 user control in the wizard page but not in step2 user control.From wizard.aspx.vb – it worksDim m_title As DropDownList = CType(Me.PersonalBox1.FindControl("ddlTitle1"), DropDownList) Question:How can I find the value of a control(textbox or dropdownlist)in step1 user control from step2 user control? I want to find “PersonalBox1.FindControl("ddlTitle1")” from Step2 AddressBox1. I have tried several ways to access it but no luck. From AddressBox.ascx.vb –...

How can javascript access to a Control in a Template Column?
I have a datagrid. And I want when I click Edit LinkButton, the program auto focus to a control. I had found whether a method of server control similar focus method in javascript. But I did not found. Please help me!The life is beautiful! Well, .focus() method in javascript should do that for you. All you need to do is supply an appropriate ID of the control. Use the ClientID property of the control at the server side to write the javascript for each EditLinkButton. I would suggest writing a separate JavaScript procedure accepting the ID of the control and setting the focus. This way y...

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

Web resources about - Control-Access in Template-Column ? - asp.net.presentation-controls

Detroit's revival template for struggling U.S. cities: Column
To save some parts of the city, other parts get short shrift.

Resources last updated: 12/23/2015 4:12:48 AM