Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 3rd, 2003, 08:01 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default datagrid dorpdownlist selected

The code
=================================
<%@ Page Language="vb" Debug="true" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)

If (Not Page.IsPostBack)
Dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;"
   strConn += "Data source=C:\website\db1.mdb;"

  Dim strSQL as string ="select skillid, SkillName from skillset "
 Dim Conn as New OLEDBConnection(strConn)
 Dim Cmd as New OLEDBCommand(strSQL,Conn)
 Conn.Open()
 dgNameList1.DataSource = Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
 dgNameList1.DataBind()
End If

End Sub
</script>

<html>
<form runat="server">

<asp:datagrid
id="dgnamelist1"
autogeneratecolumns=false runat="server">
<columns>
<asp:templatecolumn headertext="plese select">
   <itemtemplate>
   <asp:dropdownlist id="level" size=1 runat="server">
       <asp:ListItem>0</asp:ListItem>
       <asp:listitem>1</asp:listitem>
       <asp:ListItem>2</asp:ListItem>
       <asp:ListItem>3</asp:ListItem>
       <asp:ListItem>4</asp:ListItem>
       <asp:ListItem>5</asp:ListItem>
  </asp:dropdownlist>
   <asp:label id="hdnskillid" visible="false" text='<%#databinder.eval(container.dataitem,"skill id")%>' runat=server/>
   </itemtemplate>
</asp:templatecolumn>


 <asp:templatecolumn headertext="SkillName">
   <itemtemplate>
  <asp:label id="lblskillname" text='<%#databinder.eval(container.dataitem,"skill name")%>' runat=server/>
   </itemtemplate>
</asp:templatecolumn>



</columns>
</asp:datagrid>

<input type="button" id="btnselect" onserverclick="btnselect_onclick" value="select" runat="server">
</form>
</html>

Problem
====================
The table used is skillset table and has the data stored as(used for sql for above code)

skillid Skill Name
1 Java
2 .net
3 HTML
4 C++
5 Vb
And so on
.
.
Now when Skillid 1 that is Java is shown the dorpdownlist should show 5.
When skillid 2 that is .net is shown the dorpdownlist should show 1.
When skillid3 that is HTML is shown the dorpdownlist should show 2
And so on…


1. How do I do it?
2. if my pageload file was in the code behind file that is *.vb file how would I make the selection of the dropdownlist.
 
Old June 5th, 2003, 09:34 AM
Authorized User
 
Join Date: Jun 2003
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to james_sellwood
Default

What do you mean when when you say:

Quote:
quote:
Now when Skillid 1 that is Java is shown the dorpdownlist should show 5.
When skillid 2 that is .net is shown the dorpdownlist should show 1.
When skillid3 that is HTML is shown the dorpdownlist should show 2
Why should the dropdown show 5 when 1 is picked, 1 when 2 is picked and 2 when 3 is picked? What is the pattern?

If you want to show the skillid and the skillname of whichever item in the drop down list is picked you can use the dgnamelist1.selectedIndex to determine which item is picked and then add 1 to this to get the skillid. The skillid can then be used to determine the skillname.


--------------------
:) James Sellwood :)
--------------------





Similar Threads
Thread Thread Starter Forum Replies Last Post
selected records from a datagrid kanoorani VB Databases Basics 0 July 11th, 2006 12:20 AM
How to get datagrid selected index pl help me msrnivas General .NET 1 July 1st, 2005 08:03 AM
Datagrid - Scroll to selected item rodmcleay ASP.NET 1.0 and 1.1 Professional 2 February 21st, 2005 08:36 PM
How to cover only the selected lines in a DataGrid thomaz C# 3 January 19th, 2005 10:44 AM
Identifying a selected datagrid column burdickdave ASP.NET 1.x and 2.0 Application Design 0 July 30th, 2003 02:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.