Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Listbox help

Thread Tools

Listbox help

Posts: n/a
Hello Everyone,

First let me thank you for taking the time to read this post. I am
pretty new to and I have what could be a minor question about
it. I am working with a datagrid and in one of the columns there is a
multiple selection listbox. The code is pretty standard:

<asp:datagrid id="dgUsers" runat="server"
onupdatecommand="dgUsers_Update" oneditcommand="dgUsers_Edit"
oncancelcommand="dgUsers_Cancel" ondeletecommand="dgUsers_Delete"
cellpadding="2" autogeneratecolumns="false"
itemstyle-cssclass="ResultsItem" headerstyle-horizontalalign="center"
headerstyle-cssclass="TableHeader" onitemcreated="DataGridItemCreated">

<EditItemStyle CssClass="ResultsSelectedItem"></EditItemStyle>
<ItemStyle CssClass="ResultsItem"></ItemStyle>
<HeaderStyle HorizontalAlign="Center"
<asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update"
HeaderText="Action" CancelText="Cancel"
<asp:templatecolumn headertext="Databases"
<%# DataBinder.Eval(Container.DataItem, "UserDatabases") %>
<asp:ListBox ID="lbDatabases" Runat="server" SelectionMode=Multiple
datavaluefield="DBID" datatextfield="DBName"
<asp:ButtonColumn Text="Delete" ButtonType="PushButton"
HeaderText="Action" CommandName="Delete"></asp:ButtonColumn>

I removed the other fields from the datagrid because I don't feel that
they are important to this issue. The vb code associated when clicking
edit looks like this. I am just putting the part where I try to assign
the listbox to a local variable, so I can use it.

Dim lstbxDatabases As ListBox =
CType(E.Item.Cells(.FindControl("lbDatabases"), ListBox)
Dim lstbxDatabases As ListBox = E.Item.FindControl("lbDatabases")
Dim lstbxDatabases As ListBox = E.Item.Cells(.Controls(0)

I tried this each of the way above and for the first two, the value of
listbxDatabases is nothing. For the last one, I get a casting error on
the webpage. Note, I have it say that the cell is 8 because that is
where it will be on the full datagrid.

If you need any more information or if there is something noticable
that I left out, please let me know.

Thanks again for all of your time.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox selection to populate another listbox? Chris Kettenbach ASP .Net 3 06-16-2005 09:19 PM
Listbox item added with client scripts not submitting with ASP:Listbox Simon Prince ASP .Net 2 10-19-2004 04:11 PM
How do I move all items in a listbox to another listbox kent ASP .Net 1 05-03-2004 12:17 AM
click listbox and refresh another listbox DC Gringo ASP .Net 0 04-06-2004 02:13 AM
Re: now desparate! - 1st listbox contents disappears when 2nd listbox appears? blenderdude ASP .Net 0 08-03-2003 10:18 PM