473,595 Members | 2,517 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

selectedindex of multiple listbox selection in a datagrid

Lie
Hi all,

I have problem in getting selectedindex of multiple listbox selection in a
datagrid. I have a listbox with multiple selection mode inside datagrid. In
Edit mode, I need to get back all selected items of that listbox and display
it.
can anyone help?

Thanks

rgds,
Lie
Nov 19 '05 #1
5 3521
Hi Lie,

You need to get a reference to the listbox from the datagriditem that was
clicked. After that, you loop through the listbox items to see which ones
were selected. I've put some code below that demonstrates the idea.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
DataGrid1.DataS ource = CreateDataSourc e()
DataGrid1.DataB ind()
End If
End Sub

Private Sub DataGrid1_ItemC ommand _
(ByVal source As Object, ByVal e As _
System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
Handles DataGrid1.ItemC ommand
Dim lbx As ListBox
Dim lbxitm As ListItem
Dim itm As DataGridItem
itm = e.Item
lbx = itm.Cells(0).Fi ndControl("list box1")
Label1.Text = ""
For Each lbxitm In lbx.Items
If lbxitm.Selected = True Then
Label1.Text = Label1.Text & lbxitm.Text & "<br>"
End If
Next
End Sub
Function CreateDataSourc e() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add( New DataColumn _
("IntegerValue" , GetType(Int32)) )
dt.Columns.Add( New DataColumn _
("StringValu e", GetType(String) ))
dt.Columns.Add( New DataColumn _
("CurrencyValue ", GetType(Double) ))
dt.Columns.Add( New DataColumn _
("Boolean", GetType(Boolean )))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSour ce

<p>
<asp:label id="Label1" runat="server"> </asp:label></p>
<asp:datagrid id="DataGrid1" runat="server"
autogeneratecol umns="False">
<columns>
<asp:templateco lumn>
<itemtemplate >
<p>
<asp:listbox id="ListBox1" runat="server"
SelectionMode=" Multiple">
<asp:listitem
Value="Red">Red </asp:listitem>
<asp:listitem
Value="Green">G reen</asp:listitem>
<asp:listitem
Value="Blue">Bl ue</asp:listitem>
<asp:listitem
Value="White">W hite</asp:listitem>
</asp:listbox></p>
</itemtemplate>
</asp:templatecol umn>
<asp:templateco lumn HeaderText="Str ingValue">
<itemtemplate >
<asp:Label runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Strin gValue") %>'>
</asp:label>
</itemtemplate>
</asp:templatecol umn>
<asp:buttoncolu mn Text="Select"
CommandName="Se lect"></asp:buttoncolum n>
</columns>
</asp:datagrid>

"Lie" <Li*@discussion s.microsoft.com > wrote in message
news:ED******** *************** ***********@mic rosoft.com...
Hi all,

I have problem in getting selectedindex of multiple listbox selection in a
datagrid. I have a listbox with multiple selection mode inside datagrid.
In
Edit mode, I need to get back all selected items of that listbox and
display
it.
can anyone help?

Thanks

rgds,
Lie


Nov 19 '05 #2
Ken,
You example was good, but there is one line that I believe should be
simplified:

lbx = itm.Cells(0).Fi ndControl("list box1")

Since you are using a TemplateColumn, and you control the ID, it is
unnecessary to call e.Item.Cells(0) .FindControl(). You can merely call
e.Item.FindCont rol("listbox1") , and you will find the control.

--
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo
"Ken Cox [Microsoft MVP]" <BA************ @sympatico.ca> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi Lie,

You need to get a reference to the listbox from the datagriditem that was
clicked. After that, you loop through the listbox items to see which ones
were selected. I've put some code below that demonstrates the idea.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
DataGrid1.DataS ource = CreateDataSourc e()
DataGrid1.DataB ind()
End If
End Sub

Private Sub DataGrid1_ItemC ommand _
(ByVal source As Object, ByVal e As _
System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
Handles DataGrid1.ItemC ommand
Dim lbx As ListBox
Dim lbxitm As ListItem
Dim itm As DataGridItem
itm = e.Item
lbx = itm.Cells(0).Fi ndControl("list box1")
Label1.Text = ""
For Each lbxitm In lbx.Items
If lbxitm.Selected = True Then
Label1.Text = Label1.Text & lbxitm.Text & "<br>"
End If
Next
End Sub
Function CreateDataSourc e() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add( New DataColumn _
("IntegerValue" , GetType(Int32)) )
dt.Columns.Add( New DataColumn _
("StringValu e", GetType(String) ))
dt.Columns.Add( New DataColumn _
("CurrencyValue ", GetType(Double) ))
dt.Columns.Add( New DataColumn _
("Boolean", GetType(Boolean )))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSour ce

<p>
<asp:label id="Label1" runat="server"> </asp:label></p>
<asp:datagrid id="DataGrid1" runat="server"
autogeneratecol umns="False">
<columns>
<asp:templateco lumn>
<itemtemplate >
<p>
<asp:listbox id="ListBox1" runat="server"
SelectionMode=" Multiple">
<asp:listitem
Value="Red">Red </asp:listitem>
<asp:listitem
Value="Green">G reen</asp:listitem>
<asp:listitem
Value="Blue">Bl ue</asp:listitem>
<asp:listitem
Value="White">W hite</asp:listitem>
</asp:listbox></p>
</itemtemplate>
</asp:templatecol umn>
<asp:templateco lumn HeaderText="Str ingValue">
<itemtemplate >
<asp:Label runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Strin gValue") %>'>
</asp:label>
</itemtemplate>
</asp:templatecol umn>
<asp:buttoncolu mn Text="Select"
CommandName="Se lect"></asp:buttoncolum n>
</columns>
</asp:datagrid>

"Lie" <Li*@discussion s.microsoft.com > wrote in message
news:ED******** *************** ***********@mic rosoft.com...
Hi all,

I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid.
In
Edit mode, I need to get back all selected items of that listbox and
display
it.
can anyone help?

Thanks

rgds,
Lie

Nov 19 '05 #3
Lie
Hi,

Thanks for all replies.
I've tried both ways:
lbx = e.Item.FindCont rol("listbox1")
and
lbx= e.Item.Cells(8) .FindControl("l istbox1")

both return nothing ..couldn't find the control. any idea?

Thanks
rgds,
Lie

"Jeffrey Palermo [MCP]" wrote:
Ken,
You example was good, but there is one line that I believe should be
simplified:

lbx = itm.Cells(0).Fi ndControl("list box1")

Since you are using a TemplateColumn, and you control the ID, it is
unnecessary to call e.Item.Cells(0) .FindControl(). You can merely call
e.Item.FindCont rol("listbox1") , and you will find the control.

--
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo
"Ken Cox [Microsoft MVP]" <BA************ @sympatico.ca> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi Lie,

You need to get a reference to the listbox from the datagriditem that was
clicked. After that, you loop through the listbox items to see which ones
were selected. I've put some code below that demonstrates the idea.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
DataGrid1.DataS ource = CreateDataSourc e()
DataGrid1.DataB ind()
End If
End Sub

Private Sub DataGrid1_ItemC ommand _
(ByVal source As Object, ByVal e As _
System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
Handles DataGrid1.ItemC ommand
Dim lbx As ListBox
Dim lbxitm As ListItem
Dim itm As DataGridItem
itm = e.Item
lbx = itm.Cells(0).Fi ndControl("list box1")
Label1.Text = ""
For Each lbxitm In lbx.Items
If lbxitm.Selected = True Then
Label1.Text = Label1.Text & lbxitm.Text & "<br>"
End If
Next
End Sub
Function CreateDataSourc e() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add( New DataColumn _
("IntegerValue" , GetType(Int32)) )
dt.Columns.Add( New DataColumn _
("StringValu e", GetType(String) ))
dt.Columns.Add( New DataColumn _
("CurrencyValue ", GetType(Double) ))
dt.Columns.Add( New DataColumn _
("Boolean", GetType(Boolean )))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSour ce

<p>
<asp:label id="Label1" runat="server"> </asp:label></p>
<asp:datagrid id="DataGrid1" runat="server"
autogeneratecol umns="False">
<columns>
<asp:templateco lumn>
<itemtemplate >
<p>
<asp:listbox id="ListBox1" runat="server"
SelectionMode=" Multiple">
<asp:listitem
Value="Red">Red </asp:listitem>
<asp:listitem
Value="Green">G reen</asp:listitem>
<asp:listitem
Value="Blue">Bl ue</asp:listitem>
<asp:listitem
Value="White">W hite</asp:listitem>
</asp:listbox></p>
</itemtemplate>
</asp:templatecol umn>
<asp:templateco lumn HeaderText="Str ingValue">
<itemtemplate >
<asp:Label runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Strin gValue") %>'>
</asp:label>
</itemtemplate>
</asp:templatecol umn>
<asp:buttoncolu mn Text="Select"
CommandName="Se lect"></asp:buttoncolum n>
</columns>
</asp:datagrid>

"Lie" <Li*@discussion s.microsoft.com > wrote in message
news:ED******** *************** ***********@mic rosoft.com...
Hi all,

I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid.
In
Edit mode, I need to get back all selected items of that listbox and
display
it.
can anyone help?

Thanks

rgds,
Lie


Nov 19 '05 #4
Hey Lie, post the code? You may not being looking in the right cell.
"Lie" <Li*@discussion s.microsoft.com > wrote in message
news:CF******** *************** ***********@mic rosoft.com...
Hi,

Thanks for all replies.
I've tried both ways:
lbx = e.Item.FindCont rol("listbox1")
and
lbx= e.Item.Cells(8) .FindControl("l istbox1")

both return nothing ..couldn't find the control. any idea?

Thanks
rgds,
Lie


Nov 19 '05 #5
Lie
Hi Ken,

Here's the code:

<asp:datagrid id="dgAssignMM " runat="server" Width="100%"
Font-Size="X-Small" BackColor="Whit e" Font-Names="Tahoma" PageSize="20"
AutoGenerateCol umns="False" BorderColor="#C C9966" BorderStyle="No ne"
BorderWidth="1p x" CellPadding="1" DataKeyField="n o">
<SelectedItemSt yle Font-Bold="True" ForeColor="Blac k"
BackColor="Ligh tCoral"></SelectedItemSty le>
<EditItemStyl e BackColor="Ligh tCoral"></EditItemStyle>
<AlternatingIte mStyle
BackColor="Mist yRose"></AlternatingItem Style>
<ItemStyle ForeColor="#330 099"
BackColor="Whit e"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFF FCC"
BackColor="#A51 C44"></HeaderStyle>
<FooterStyle ForeColor="#330 099"
BackColor="#FFF FCC"></FooterStyle>
<Columns>
<asp:TemplateCo lumn HeaderText="Act ion"
ItemStyle-VerticalAlign=T op >
<HeaderStyle Wrap="False" HorizontalAlign ="Center"
Width="10%"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
<ItemTemplate >
<asp:ImageButto n id="Imagebutton 6" runat="server"
AlternateText=" Edit Data" Imageurl="../images/edit_mm.gif"
CommandName="ed it"></asp:ImageButton >
<asp:ImageButto n id="ImageButton 5" runat="server"
AlternateText=" Edit Data" Imageurl="../images/Delete_mm.gif"
CommandName="de lete"></asp:ImageButton >
</ItemTemplate>
<EditItemTempla te>
<asp:ImageButto n id="Imagebutton 7" runat="server"
AlternateText=" Save Data" Imageurl="../images/save_mm.gif"
CommandName="up date"></asp:ImageButton >
<asp:ImageButto n id="Imagebutton 8" runat="server"
AlternateText=" Cancel Updates" Imageurl="../images/Cancel_mm.gif"
CommandName="ca ncel"></asp:ImageButton >
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="DIR UserID"
ItemStyle-VerticalAlign=T op>
<HeaderStyle Wrap="False"
HorizontalAlign ="Center"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
<ItemTemplate >
<%# Container.DataI tem("dir_id") %>
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id="ddlDIR_ID" runat="server"
Font-Size="8pt" SelectedIndex=' <%#
GetSelectedInde x("dir_id",Cont ainer.DataItem( "dir_id")) %>'
DataValueField= "dir_id" DataTextField=" dir_id"
DataSource='<%# GetSource("dir_ id")%>'>
</asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="MM Head UserID"
ItemStyle-VerticalAlign=T op >
<HeaderStyle Wrap="False"
HorizontalAlign ="Center"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
<ItemTemplate >
<%# Container.DataI tem("mm_head") %>
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id="ddlMM_head " runat="server"
Font-Size="8pt" SelectedIndex=' <%#
GetSelectedInde x("mm_head",Con tainer.DataItem ("mm_head")) %>'
DataValueField= "mm_head" DataTextField=" mm_head"
DataSource='<%# GetSource("mm_h ead")%>'>
</asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="MM UserID"
ItemStyle-VerticalAlign=T op>
<HeaderStyle Wrap="False"
HorizontalAlign ="Center"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
<ItemTemplate >
<%# Container.DataI tem("username") %>
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id=ddlName runat="server"
Font-Size="8pt" DataValueField= "username" DataTextField=" username"
DataSource='<%# GetSource("user name")%>' SelectedIndex=' <%#
GetSelectedInde x("username",Co ntainer.DataIte m("username") ) %>'>
</asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Cus t Sector"
ItemStyle-VerticalAlign=T op>
<HeaderStyle Wrap="False"
HorizontalAlign ="Center"></HeaderStyle>
<ItemTemplate >
<%# Container.DataI tem("custsector ")%>
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id="ddlCustSect or" runat="server"
Font-Size="8pt" DataValueField= "custsector " DataTextField=" custsector"
DataSource='<%# GetSource("cust sector")%>' SelectedIndex=' <%#
GetSelectedInde x("custsector", Container.DataI tem("custsector ")) %>'>
</asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Ind ustry Code"
ItemStyle-VerticalAlign=T op >
<HeaderStyle Wrap="False"
HorizontalAlign ="Center"></HeaderStyle>
<ItemTemplate >
<%# Container.DataI tem("industry_c ode")%>
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id="ddlIndustry _code"
runat="server" Font-Size="8pt" DataValueField= "Industry_C ode"
DataTextField=" Industry_Code" DataSource='<%# GetSource("Indu stry_Code")%>'
SelectedIndex=' <%#
GetSelectedInde x("Industry_Cod e",Container.Da taItem("Industr y_Code")) %>'>
</asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="SVC _AMG"
ItemStyle-VerticalAlign=T op>
<HeaderStyle Wrap="False"
HorizontalAlign ="Center"></HeaderStyle>
<ItemTemplate >
<%# Container.DataI tem("svc_amg")% >
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id="ddlsvc_amg " runat="server"
Font-Size="8pt" DataValueField= "svc_amg" DataTextField=" svc_amg"
DataSource='<%# GetSource("svc_ amg")%>' SelectedIndex=' <%#
GetSelectedInde x("svc_amg",Con tainer.DataItem ("svc_amg")) %>'>
</asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Cou ntry"
ItemStyle-VerticalAlign=T op>
<HeaderStyle Wrap="False"
HorizontalAlign ="Center"></HeaderStyle>
<ItemTemplate >
<%# Container.DataI tem("country")% >
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id="ddlCountry " runat="server"
Font-Size="8pt" DataValueField= "country" DataTextField=" country"
DataSource='<%# GetSource("coun try")%>' SelectedIndex=' <%#
GetSelectedInde x("country",Con tainer.DataItem ("country")) %>'>
</asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="cus tsector Test"
ItemStyle-VerticalAlign=T op>
<HeaderStyle Wrap="False"
HorizontalAlign ="Center"></HeaderStyle>
<ItemTemplate >
<asp:Label ID="lblCustSect or"><%#
Container.DataI tem("custsector ")%></asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:ListBox ID=lstCustSecto r Runat=server
Font-Size="8pt" DataValueField= "custsector " DataTextField=" custsector"
DataSource='<%# GetSource("cust sector")%>'></asp:ListBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
<PagerStyle HorizontalAlign ="Center" ForeColor="#330 099"
BackColor="#FFF FCC"></PagerStyle>
</asp:datagrid>
Public Function GetSource(ByVal col As String)
Dim dt As New DataTable()
Select Case col.ToLower
Case "dir_id"
dt = CorpHandler.Get MMUsername("dir _id", "")
Case "mm_head"
dt = CorpHandler.Get MMUsername("mm_ head", "")
Dim newRow As DataRow
newRow = dt.NewRow
newRow(0) = ""
dt.Rows.Add(new Row)

Case "username"
dt = CorpHandler.Get MMUsername("use rname", "")
Dim newRow As DataRow
newRow = dt.NewRow
newRow(0) = ""
dt.Rows.Add(new Row)

Case "custsector "
dt = CorpHandler.Get MMCustSector
Dim newRow As DataRow
newrow = dt.NewRow
newrow(0) = "ALL"
dt.Rows.InsertA t(newrow, 0)

Case "industry_c ode"
dt = CorpHandler.Get MMIndustryCode
Dim newRow As DataRow
newrow = dt.NewRow
newrow(0) = "ALL"
dt.Rows.InsertA t(newrow, 0)

Case "svc_amg"
dt = CorpHandler.Get MMSVC_AMG
Dim newRow As DataRow
newrow = dt.NewRow
newrow(0) = "ALL"
dt.Rows.InsertA t(newrow, 0)

Case "country"
dt = CorpHandler.Get MMCountry
Dim newRow As DataRow
newrow = dt.NewRow
newrow(0) = "ALL"
dt.Rows.InsertA t(newrow, 0)
End Select
Return dt
End Function

Function GetSelectedInde x(ByVal col As String, ByVal value As Object) As
Integer
Dim bEmpty As Boolean = False
Dim row As DataRow
Dim iLoop As Integer
Dim iSel As Integer = -1
Dim sData As String
Dim sValue As String

Dim dt As New DataTable()
dt = GetSource(col)

For iLoop = 0 To dt.Rows.Count - 1
If IsDBNull(dt.Row s(iLoop)(col)) Then
sData = "-9999"
Else
sData = dt.Rows(iLoop)( col)
End If

If IsDBNull(value) Then
sValue = "-9999"
Else
sValue = value.ToString. Trim.ToUpper
End If
If sValue = sData Then
'Return iLoop
iSel = iLoop
Exit For
End If

Next iLoop

If iSel = -1 Then
For iLoop = 0 To dt.Rows.Count - 1
If IsDBNull(dt.Row s(iLoop)(col)) Then
sData = "-9999"
Else
sData = dt.Rows(iLoop)( col)
End If
If sData = "" Then
Return iLoop
End If
Next
Else
Return iSel
End If
dt.Dispose()
End Function
Private Sub dgAssignMM_Item Command(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
dgAssignMM.Item Command
Dim lbx As ListBox
Dim lbxitm As ListItem
Dim itm As DataGridItem
Dim arr As Array
itm = e.Item
'lbx = e.Item.FindCont rol("lstCustSec tor")
'e.Item.Cells(9 ).FindControl(" lstcustsector")

arr = Split(CType(e.I tem.FindControl ("lblCustSector "), Label).Text,
",")
' don't know what to put here .. as i can't get the control..

End Sub

in display, custsector is in label control. Only after pressing EDIT, we
will display in listbox with its multiple selection selected .. but i still
have no idea how to get those selected value from label to listbox.

Thanks
rgds,
Lie

"Ken Cox [Microsoft MVP]" wrote:
Hey Lie, post the code? You may not being looking in the right cell.
"Lie" <Li*@discussion s.microsoft.com > wrote in message
news:CF******** *************** ***********@mic rosoft.com...
Hi,

Thanks for all replies.
I've tried both ways:
lbx = e.Item.FindCont rol("listbox1")
and
lbx= e.Item.Cells(8) .FindControl("l istbox1")

both return nothing ..couldn't find the control. any idea?

Thanks
rgds,
Lie


Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
41060
by: Russell Campbell | last post by:
Posting again, since my first attempt never appeared: In the onClick method of a listbox, I am attempting to retrieve the selectedIndex property. The listbox is set up to allow multiple selections. Unfortunately, the property returns -1. Clicking again returns the proper result. Yet when I do the same thing on the same listbox after changing it to allow only one entry to be selected, it always returns the proper result on the first...
2
1752
by: Richard Loupatty | last post by:
I put a datagrid in a panel with an overflow set on auto. I want to show just 5 items in the grid. My question is how to make sure that the selecteditem is always visible in the grid. Because now i have this situation that after each selection (I use the itemcommand) the grid starts from the top. when i (for example) set selectedindex = 8, the selection is made, but not visible to me. I have to scroll down first.
0
1356
by: Adis | last post by:
Asp.Net Visual Studio 2003 SQL Server. Hi, I have database in Sqlserver and ListBox (Multiple Selection Mode) in my Visual Studio Webform. I wish obtain various records from My_Store_Procedure and fill dataset.
1
2642
by: Carlo Marchesoni | last post by:
I'm going crazy with this. I just added two Listboxes (lbxSource->multiple selection and lbxDestination -> single selection). Then: a) button "Load": ListItem l0 = new ListItem("01"); lbxDestination.Items.Add(l0); //1st goes to Destination Box ListItem l1 = new ListItem("02"); lbxSource.Items.Add(l1); ListItem l2 = new ListItem("03"); lbxSource.Items.Add(l2);
2
3113
by: Dolorous Edd | last post by:
Hi, for a program I'm working on I need to be able to drag multiple files between Windows Explorer and a ListBox, in both directions. Implementing the "drag in" was pretty easy, but I can't find a way to export more than on item at time. The ideal result would be to be able to drag the selected files, but as soon as I click on the LB to do the drag a new selection is made that cancels the current one and by searching with google it...
3
6705
by: Magnus | last post by:
Im using a set combobox (ComboBox1) to provide a selection of records from a database table. I have a typed dataset (DataSet1) that contains the typed datatable (DataTable1) that the combobox is bound to. The datatable in the dataset is filled using the typed tableadapter (TableAdapter1). DataTable consists of the typical primary key and value fields. Here is the designer generated code for ComboBox1: this.ComboBox1.DataSource =...
3
2620
by: Alec MacLean | last post by:
Hi, I have a couple of win forms where I am editing values that are stored in a SQL database. I'm using the listbox control to hold the data object each form interacts with. Each object is defined by my own classes. On the first form, I use an approach to reduce the number of database calls. This essentially consists of :
2
1775
by: amtamayo | last post by:
I have a simple webform that has a listbox that I bind to a dataview at designtime. This provides an optional selection for the user so I wanted to have no default value selected. So on the Page_Load event, I set the selectedIndex to -1. However, when I run the page, the default value is still 0, which forces the first item to be automatically selected. I tried a bunch of things. I tried setting it to 0, then -1. I tried to call...
1
2762
by: Marisa | last post by:
Hi. I am new to C#, and I am having trouble getting the multiple selection of listbox to work. I have an asp.net web form, and I need two listboxes which are filled with an access table. I have to be able to select multiple items, and fill a datagrid with the results. I can fill 2 listboxes and a datagrid, but not with multiple selections. So far, I have no code behind, I have completed it with just using the characteristics of the...
0
7955
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
7883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8019
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8251
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5418
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3873
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2391
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.