Hi, I found an error in the example: I. In the Itemdatabound save the item index in the Dropdownlist1: ctype(me.datagrid.items(e.itemindex).cells(ddColumn).findcontrol("Dropdownlist1"),dropdownlist).Attributes.add("itemindex",e.itemindex) II. In the Dropdownlist1_SelectedIndexChanged: ItIndex as integer = ctype(sender,dropdownlist).Attributes("itemindex") ctype(me.datagrid.items(ItIndex ).cells(intddColumn1).findcontrol("dd2"),dropdownlist).datasource = YourDataSource ctype(me.datagrid.items(ItIndex ).cells(intddColumn2).findcontrol("dd2"),dropdownlist).databind You welcome! emorales mcdba, mcad, mcsd
emorales
Posts
-
dynamic dropdownlist in datagrid -
dynamic dropdownlist in datagridHi, Do the following, 1. Change autopostback to the first dd 2. On the First dd write in the aspx code 3. Write in the behind code Public Sub Dropdownlist1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) End Sub To access to the others dd you will need the item id and the column where those are located. You can do the following= I. In the Itemdatabound save the item index in the Dropdownlist1: ctype(me.datagrid.items(1).cells(ddColumn).findcontrol("Dropdownlist1"),dropdownlist).Attributes.add("itemindex",e.itemindex) II. In the Dropdownlist1_SelectedIndexChanged: ItIndex as integer = ctype(me.datagrid.items(1).cells(ddColumn).findcontrol("Dropdownlist1"),dropdownlist).Attributes("itemindex") ctype(me.datagrid.items(ItIndex ).cells(intddColumn).findcontrol("dd2"),dropdownlist).datasource = YourDataSource ctype(me.datagrid.items(ItIndex ).cells(intddColumn).findcontrol("dd2"),dropdownlist).databind Happy Programming emorales mcdba, mcad, mcsd
-
TemplateColumn - QuestionSorry the past reply is wrong. This is the correct Reply. Hi, Wow, C# is different! Anyway, here is an example for you. I confused with the properties (CommandArgument and CommandName. There is two properties that you have to understand. First is CommandName This property is the name of the command, that means here you will write the action that you want to do. Second is CommandArgument This is a property to set any value that you want access in the moment that ItemCommand event raise. Where you can set this property? In the datagird.ItemDataBound. You will notice that did not use the FindControl in the Datagrid.ItemCommand. I haved to look my own code to verify and create this example. The following code is a web form that I programed for you. Is running very well and is a good example. Add a web form in your project and then copy and paste the code in the web form and behind code. ------------------------------- Web Form ------------------------------- <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="test.WebForm1" %> WebForm1
Label
LinkButton
----------------------------------------------------- Behind Code ----------------------------------------------------- using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlC
-
TemplateColumn - QuestionYou welcome, I think you have an extra parentesis. void datagrid_itemcommand(object sender, DataGridCommandEventArgs e) { Label1.Text=( (LinkButton)(e.Item.Cells(0).FindControl("lnkFullText") ) ) .Text); 1 2 2 3 4 4 5 5 3 ? 1 Delete the ? parentesis. The correct sentence is: Label1.Text=( (LinkButton)(e.Item.Cells(0).FindControl("lnkFullText") ) .Text); } Check that, and let me know. Remember, you can access any child controls in any control using "control".findcontrol("childcontrol") using a datatype conversion. emorales mcdba, mcad, mcsd
-
TemplateColumn - QuestionSorry, I forgot explain how to get the linkbutton's properties within datagrid. First we do a findcontrol in the cell where is it located of the item., Then you will do a ctype for the type of the control that you will access. Finally you will access to the control's properties. example: ctype(e.item.cells(0).findcontrol("controlID"), LinkButton).CommandArgument ctype(e.item.cells(0).findcontrol("controlID"), LinkButton).Text ctype(e.item.cells(0).findcontrol("controlID"), LinkButton).Enable . . . 1. cells(0): Change the 0 for the cell number where the control is located. 2. FindControl("ControlID"): Change the ControlID for the LinkButton.id property that you gave to the control. 3. Ctype(object,datatype): You have to do a ctype to access the properties of the control. Happy Programming, emorales mcdba, mcad, mcsd
-
TemplateColumn - QuestionHI, In the code where you wrote datagrid.datasource = data add another line: datagrid.datakeysfield=columnkey In the datagrid_itemcommand event write the following: sub datagrid_itemcommand(sender, e) dim itemkey as integer = datagrid.datakeys(e.item.itemindex) select case e.itemcommand case "LinkButton 's commandargument" Your code! case "another control's commandargument" case "another control's commandargument" ens case end sub Let me know if this is do you want to do emorales mcdba, mcad, mcsd
-
Button Text to wrap to second lineYou can write "
" tag between words in the Button's Text property. emorales mcdba, mcad, mcsd -
I Need a quick tip i'm new to ASPYou will need a class that inherits from System.Web.Ui.Page and then your both pages ingertis from your custom class. I'll try to write an article for the next week about this. I'll let you know. emorales mcdba, mcad, mcsd