473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help with Dynamic Details View List Box

Hi All,
How do I add a List Box to a dynamic Details View. I want to replace
the check boxes with list boxes. If I try to simply replace the check
box with a list box it complains about not being able to convert it to
a datacontrol field. Below is a portion of my current code behind. By
the way I tried doing dynamic templates and was not able to get it to
work. Please help, this is driving me nuts.

Thanks
Dim DetailsViewAudit As New DetailsView()
Dim UpdateString As String = Nothing
Dim UpdateParam As String = Nothing

sSQL = "Select * from [Audit Formats] where [Audit Type]='" &
AuditType & "' order by [Rank]"
oCmd = New SqlCommand(sSQL, oCnn)

'start the update string
UpdateString = "UPDATE [" & TypeName & "] SET "

Dim drAuditFormat As SqlDataReader = oCmd.ExecuteReader()
Dim DetailsField As New BoundField()
Dim DetailsCheckBox As New CheckBoxField()

DetailsField.HeaderText = "UniqueKey"
DetailsField.DataField = "UniqueKey"
DetailsField.Visible = False
DetailsViewAudit.Fields.Add(DetailsField)

Do While (drAuditFormat.Read())

If drAuditFormat(4) <"AssessmentNumber" Then 'skip
assessment number
UpdateParam = "[" & drAuditFormat(4) & "]=@" &
drAuditFormat(4) & ","
UpdateString = UpdateString & UpdateParam
End If

Select Case drAuditFormat(3)
Case 1 'text box field
DetailsField = New BoundField()
DetailsField.DataField = drAuditFormat(4)
DetailsField.HeaderText = drAuditFormat(5)

Select Case drAuditFormat(4)
Case "AssessmentNumber"
DetailsField.Visible = False
DetailsField.ReadOnly = True 'set
assessment number to read only
Case "CorrectiveAction"
DetailsField.ItemStyle.Wrap = True
DetailsField.ItemStyle.Height = 150
DetailsField.ItemStyle.Width = 150
DetailsField.ItemStyle.VerticalAlign =
VerticalAlign.Top
DetailsField.ControlStyle.CssClass =
"WrapText" 'not working yet
End Select

DetailsViewAudit.Fields.Add(DetailsField)
Case 2 'check box field
DetailsCheckBox = New CheckBoxField
DetailsCheckBox.DataField = drAuditFormat(4)
DetailsCheckBox.HeaderText = drAuditFormat(5)
DetailsCheckBox.Text = "Comply"
DetailsViewAudit.Fields.Add(DetailsCheckBox)
End Select

Loop

drAuditFormat.Close()

PlaceHolderDetails.Controls.Add(DetailsViewAudit)

Dim keyArray() As String = {"UniqueKey"}
DetailsViewAudit.DataKeyNames = keyArray

DetailsViewAudit.AutoGenerateEditButton = True
DetailsViewAudit.AutoGenerateRows = False
DetailsViewAudit.Fields(2).HeaderStyle.Width = 6000
DetailsViewAudit.Fields(2).ItemStyle.Width = 300
DetailsViewAudit.CellPadding = 0
DetailsViewAudit.CellSpacing = 1

SqlDataSourceDetail.ConnectionString =
("MyDataSource") SqlDataSourceDetail.SelectCommandType
= SqlDataSourceCommandType.Text
SqlDataSourceDetail.SelectCommand = "SELECT * FROM [" &
TypeName & "] where AssessmentNumber='" & AuditNumber & "'"

SqlDataSourceDetail.UpdateCommandType =
SqlDataSourceCommandType.Text

'finalize update string
UpdateString = Mid(UpdateString, 1, Len(UpdateString) - 1) & "
WHERE AssessmentNumber='" & AuditNumber & "'"
SqlDataSourceDetail.UpdateCommand = UpdateString
DetailsViewAudit.DataSourceID = "SqlDataSourceDetail"

'DetailsViewAudit.DataBind() 'not required

AddHandler DetailsViewAudit.ModeChanging, AddressOf
DetailsViewAudit_ModeChanging
AddHandler DetailsViewAudit.ItemUpdating, AddressOf
DetailsViewAudit_ItemUpdating
AddHandler DetailsViewAudit.ItemUpdated, AddressOf
DetailsViewAudit_ItemUpdated

Mar 31 '07 #1
0 1399

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

Similar topics

1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
3
by: sferriol | last post by:
hello is it possible with postgres 7.2 or more, to define a dynamic view. For example, i have a table with a column 'user' and i want to define a view which gives infomrations from different...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
2
by: StevenChiasson | last post by:
For the record, not a student, just someone attempting to learn C++. Anyway, the problem I'm having right now is the member function detAddress, of object controller. This is more or less, your...
3
by: Alami | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
16
by: gnawz | last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) ...
0
by: richard12345 | last post by:
Hi Guys I have problem with site I am building. The sidebar with menu and other thinks is overlapping footer. The footer move with the content and but it dos it dos not move with the sidebar. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.