Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > EditItemTemplate's DropDownList problem

Reply
Thread Tools

EditItemTemplate's DropDownList problem

 
 
asp.net
Guest
Posts: n/a
 
      03-09-2005
I have follow the instruction from the web.

http://aspnet.4guysfromrolla.com/demos/dgExample16.aspx

When I was trying to implement new codes in order to fit my problems,
error occurs.
I was trying to mount 3 dropdownlist. Pls have a look at the following
code.


<vb code>
Dim ds as DataSet = New DataSet()
Dim m_id As String
Dim dbconn As OleDbConnection

Function GetCategories(type As String) as DataSet

Dim sql as String = "SELECT * FROM [" & type & "Detail]"
Dim myDataAdapter as OleDbDataAdapter = New OleDbDataAdapter(sql,
dbconn)
myDataAdapter.Fill(ds, type)

Return ds

End Function

Function GetSelectedIndex(CID as String, type as string) as Integer
Dim iLoop as Integer

Dim dt as DataTable = ds.Tables(type)
For iLoop = 0 to dt.Rows.Count - 1
If Int32.Parse(CID) = Int32.Parse(dt.Rows(iLoop)("ID")) then
Return iLoop
End If
Next iLoop

End Function

Sub BindList()
dim dataAdaptor As OleDbDataAdapter
dim dss As DataSet
dim sql As String

sql="SELECT APAC.*, IIf(IsNull(APAC.[Source]),1,SourceDetail.ID) AS
[Source ID], " &_
"IIf(IsNull(APAC.[Keyword 1]),1,[Keyword1Detail].ID) AS [Keyword 1 ID],
" &_
"IIf(IsNull(APAC.[Keyword 2]),1,[Keyword2Detail].ID) AS [Keyword 2 ID]
FROM " &_
"((APAC LEFT JOIN SourceDetail ON APAC.Source = SourceDetail.Source)
LEFT JOIN " &_
"[Keyword1Detail] ON APAC.[Keyword 1] = [Keyword1Detail].[Keyword 1])
LEFT JOIN " &_
"[Keyword2Detail] ON APAC.[Keyword 2] = [Keyword2Detail].[Keyword 2]
WHERE APAC.ID = " & m_id
dataAdaptor=New OleDbDataAdapter( sql, dbconn )
dss=New DataSet
dataAdaptor.Fill(dss,"details")

MyDataList.DataSource = dss.Tables("details").DefaultView
MyDataList.DataBind()
End Sub

</code>


<html code>

<EditItemTemplate>
<div style="padding:15,15,15,15;font-size:10pt;font-family:Verdana">
<div style="font:12pt verdana;color:darkred">
APAC</b>
</div>
<br />
Keyword 1:
<aspropDownList runat="server" id="Keyword1" DataValueField="ID"
DataTextField="Keyword 1"
DataSource='<%# GetCategories("Keyword1") %>'
SelectedIndex='<%# GetSelectedIndex(Container.DataItem("Keyword 1
ID"),"Keyword1") %>' />
<br />
<p></p>
Keyword 2:
<aspropDownList runat="server" id="Keyword2" DataValueField="ID"
DataTextField="Keyword 2" DataSource='<%# GetCategories("Keyword2") %>'
SelectedIndex='<%# GetSelectedIndex(Container.DataItem("Keyword 2
ID"),"Keyword2") %>' />
<br />
<p></p>
Source:
<aspropDownList runat="server" id="source" DataValueField="ID"
DataTextField="Source" DataSource='<%# GetCategories("Source") %>'
SelectedIndex='<%# GetSelectedIndex(Container.DataItem("Source
ID"),"Source") %>' />
<br />
<p></p>
Question:
<p></p>
<asp:TextBox id="question" textmode="MultiLine" AutoPostBack="true"
width="100%" height="200" Text='<%# DataBinder.Eval(Container.DataItem,
"Question") %>' runat="server" />
<br />
<p></p>
Answer:
<p></p>
<asp:TextBox id="answer" textmode="MultiLine" AutoPostBack="true"
width="100%" height="200" Text='<%# DataBinder.Eval(Container.DataItem,
"Answer") %>' runat="server" />
<p></p>
<p></p>
<asp:linkbutton CommandName="Update" runat="server">
<img border="0" src="update_book.gif" />
</asp:linkbutton>
&nbsp&nbsp
<asp:linkbutton CommandName="Cancel" runat="server">
<img border="0" src="cancel_book.gif" />
</asp:linkbutton>
</div>
</EditItemTemplate>

</code>

>From the error message I obtained, the error should be caused by the

Sub BindList.
But the code works fine when there's only one dropdown box in
EditItemTemplate.

Thans

 
Reply With Quote
 
 
 
Reply

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
DropDownList inside GridView: How to set SelectedIndex for the DropDownList? keithb ASP .Net 1 11-01-2006 05:24 AM
GridView: Filter DropDownList for another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-29-2005 07:44 AM
GridView: Filtr DropDownList from another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-23-2005 01:31 PM
databinding a Dropdownlist to another dropdownlist tshad ASP .Net 8 10-19-2005 10:00 PM
Using a data-bind dropdownlist to populate another data-bind dropdownlist mr2_93 ASP .Net 1 10-02-2005 05:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57