|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataGrid with edititemtemplateHi
I have a datagrid defined which I would like to make it editable. So I put in some editcommand and BoundColumn and template column with item template. I don't have problem in setting a column to textbox in edititemtemplate, but how do I set it to dropdownlist and how do I set the selectedIndex? TIA -- You can handle the DataGrid's ItemDataBound event. The DataGridItemEventArgs
passed allows you to access the e.Item which is the row in the DataGrid. Find the cell you want, then use FindControl("IDOfYourDDL") to get your DropDownList in the Cell. Once you have that, you can do any custom work with it you need to. -Brock DevelopMentor http://staff.develop.com/ballen Show quoteHide quote > Hi > I have a datagrid defined which I would like to make it editable. So I > put > in some editcommand and BoundColumn and template column with item > template. > I don't have problem in setting a column to textbox in > edititemtemplate, but > how do I set it to dropdownlist and how do I set the selectedIndex? > TIA > Do you mean I should use ItemDataBound event to bind data to the
dropdownlist control and disable it before the DataGrid got displayed, then onEditCommand event, I simply enable the control? TIA Show quoteHide quote "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message news:889665632542634599814224@msnews.microsoft.com... > You can handle the DataGrid's ItemDataBound event. The DataGridItemEventArgs > passed allows you to access the e.Item which is the row in the DataGrid. > Find the cell you want, then use FindControl("IDOfYourDDL") to get your DropDownList > in the Cell. Once you have that, you can do any custom work with it you need > to. > > -Brock > DevelopMentor > http://staff.develop.com/ballen > > > > > Hi > > I have a datagrid defined which I would like to make it editable. So I > > put > > in some editcommand and BoundColumn and template column with item > > template. > > I don't have problem in setting a column to textbox in > > edititemtemplate, but > > how do I set it to dropdownlist and how do I set the selectedIndex? > > TIA > > > > > To change the Selected item in the DDL, you're going to have to get access
to the DDL. This can be accomplished by handling the ItemDataBound event on the Grid. Oh, one other thing I should have mentioned is that since you're only doing this when you edit the row, you should double check for e.Item.ItemType == ListItemType.EditItem. Oh, just rereading your original post, I think what you're going to want is to put a EditItemTemplate. Inside of that put your own DDL. And then, yes, in the ItemDataBound you can data bind the DDL to whatever list it needs to be. -Brock DevelopMentor http://staff.develop.com/ballen Show quoteHide quote > Do you mean I should use ItemDataBound event to bind data to the > dropdownlist control and disable it before the DataGrid got displayed, > then onEditCommand event, I simply enable the control? > > TIA > > "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message > news:889665632542634599814224@msnews.microsoft.com... > >> You can handle the DataGrid's ItemDataBound event. The >> > DataGridItemEventArgs > >> passed allows you to access the e.Item which is the row in the >> DataGrid. Find the cell you want, then use FindControl("IDOfYourDDL") >> to get your >> > DropDownList > >> in the Cell. Once you have that, you can do any custom work with it >> you >> > need > >> to. >> >> -Brock >> DevelopMentor >> http://staff.develop.com/ballen >>> Hi >>> I have a datagrid defined which I would like to make it editable. So >>> I >>> put >>> in some editcommand and BoundColumn and template column with item >>> template. >>> I don't have problem in setting a column to textbox in >>> edititemtemplate, but >>> how do I set it to dropdownlist and how do I set the selectedIndex? >>> TIA Hi, Brock.
I've spent the past 5 hours on this problem, trying to figure out how to change the SelectedValue, something that should really only take 30 second. I've stumped three other developers in my small office. With your help I still can't quite get it. I have a static list for the DDL but I need to change the SelectedValue to the data that's being edited in the template column of the DataList. I'm not inputting the list from a DataReader or anything. The problem is I can't access or find the DDL control. I've got a hunch that the control I want might not exist when I am trying to access it, since it's built on-the-fly (template). I've got a dl_EditCommand sub and a dl_ItemDataBound (I just added this one as per your suggestion). When I click "Edit", ItemDataBound fires before the EditCommand is fired. Is there a method that fires later than these two? Help is much appreciated! -- Show quoteHide quoteEric "Brock Allen" wrote: > To change the Selected item in the DDL, you're going to have to get access > to the DDL. This can be accomplished by handling the ItemDataBound event > on the Grid. Oh, one other thing I should have mentioned is that since you're > only doing this when you edit the row, you should double check for e.Item.ItemType > == ListItemType.EditItem. > > Oh, just rereading your original post, I think what you're going to want > is to put a EditItemTemplate. Inside of that put your own DDL. And then, > yes, in the ItemDataBound you can data bind the DDL to whatever list it needs > to be. > > -Brock > DevelopMentor > http://staff.develop.com/ballen > > > Do you mean I should use ItemDataBound event to bind data to the > > dropdownlist control and disable it before the DataGrid got displayed, > > then onEditCommand event, I simply enable the control? > > > > TIA > > > > "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message > > news:889665632542634599814224@msnews.microsoft.com... > > > >> You can handle the DataGrid's ItemDataBound event. The > >> > > DataGridItemEventArgs > > > >> passed allows you to access the e.Item which is the row in the > >> DataGrid. Find the cell you want, then use FindControl("IDOfYourDDL") > >> to get your > >> > > DropDownList > > > >> in the Cell. Once you have that, you can do any custom work with it > >> you > >> > > need > > > >> to. > >> > >> -Brock > >> DevelopMentor > >> http://staff.develop.com/ballen > >>> Hi > >>> I have a datagrid defined which I would like to make it editable. So > >>> I > >>> put > >>> in some editcommand and BoundColumn and template column with item > >>> template. > >>> I don't have problem in setting a column to textbox in > >>> edititemtemplate, but > >>> how do I set it to dropdownlist and how do I set the selectedIndex? > >>> TIA > > > >
Page values are lost
What happened to Alignment property? Specifying Width and Height properties as percentages navigate through multipage hiddenfield / htmlInputHidden ? more than one webroot Getting the ApplicationInstance in webcontrol? Help Problems with ListBox Control Catch the page closing event Dropdownlist doesnot allow child control. |
|||||||||||||||||||||||