Tôi có bảng cơ sở dữ liệu Prospect
để lưu trữ khách hàng tiềm năng có id khóa chính & phiên bản. Có một nút radio Generate Proposal
trong biểu mẫu web, khi được nhấp vào sẽ hiển thị hộp thoại để cho phép người dùng chọn phiên bản của khách hàng tiềm năng để tạo từ hộp thả xuống. Tôi có một phương pháp mà sẽ lấy các phiên bản từ cơ sở dữ liệu cho các khách hàng tiềm năng GetVersions()
nhưng không có ý tưởng làm thế nào để đặt nó trong một hộp thoại để cho phép người dùng chọn phiên bản. Bất kỳ trợ giúp nào cũng được đánh giá rất cao.Hộp thoại có các tùy chọn được truy xuất từ cơ sở dữ liệu
5
A
Trả lời
2
Giao diện người dùng JQuery có phải là một tùy chọn không?
Bạn sẽ phải thêm LIỆU THAM KHẢO JQuery UI có thể tìm thấy Here
Here is the documentation on the JQuery UI dialog.
Mã dưới đây được chụp từ một giải pháp mà tôi thực hiện. Tôi đã xóa một vài đoạn mã để đơn giản. Hãy cho tôi biết nếu bạn cần làm rõ.
HTML:
<div id="MenuChangeSelection" title="Change Selection" class="MainDialog">
<div id="MenuChangeSelectionContent"></div>
</div>
JQuery:
$("#YourRadBtnID").click(function() {
var yourDropDownMarkup = "<select><option value='Opt1'>Opt1</option></select>"; // Insert your dropdown markup or get your dropdown from the dom.
$("#MenuChangeSelectionContent").html(yourDropDownMarkup);
$("#MenuChangeSelection").dialog({
autoOpen: true,
modal: true,
width: 600,
height: 150,
buttons: {
"Save And Close": function() {
//Do something when Save And Close is clicked. eg. asynchronously post back to server.
},
"Cancel": function() {
$(this).dialog("close");
}
},
open: function() {
$('.ui-widget-overlay').addClass('custom-overlay');
},
close: function() {
$('.ui-widget-overlay').removeClass('custom-overlay');
}
});
});
CSS:
.ui-widget-overlay.custom-overlay
{
background-color:black;
opacity:0.4;
filter:alpha(opacity=40); /* For IE8 and earlier */
}
2
Dưới đây là một đoạn nhỏ để giúp bạn bắt đầu. Điều này sử dụng jQuery Dialog Box.
Trong trang aspx
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<asp:Button ID="generateProposal" runat="server" Text="Generate Proposal" OnClick="generateProposal_Click" />
<div id="popupContent" style="display: none">
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click1" />
</div>
<script type="text/javascript">
function showPopup() {
$(function() {
$("#popupContent").dialog();
});
}
</script>
Và sau đó trong mã phía sau.
protected void generateProposal_Click(object sender, EventArgs e)
{
//the id of the prospect. Not clear from your question where this should come from
int proposalID = 6;
//sometimes a counter is just a counter
int counter = 0;
//clear old items from the dropdownlist
DropDownList1.Items.Clear();
//load the prospects from the database here and attach to dropdownlist
using (SqlConnection connection = new SqlConnection(connectionString))
using (SqlCommand command = new SqlCommand("prospect_select", connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@id", SqlDbType.Int).Value = proposalID;
try
{
//open the database connection
connection.Open();
SqlDataReader reader = command.ExecuteReader();
//loop all rows and add them to the dropdownlist
while (reader.Read())
{
DropDownList1.Items.Insert(counter, new ListItem(reader["prospect_name"].ToString(), reader["prospect_version"].ToString(), true));
counter++;
}
}
catch (Exception exception)
{
//handle the error if you want
}
}
//call the javascript function to open the dialog box
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "showPopup", "showPopup();", true);
}
Các vấn đề liên quan
- 1. Làm cách nào để truy xuất dữ liệu từ Cơ sở dữ liệu Firebase?
- 2. WPF MVVM truy xuất dữ liệu được chọn các hàng
- 3. Truy vấn LINQ có thể truy xuất BLOB từ Cơ sở dữ liệu Sql không?
- 4. Lỗi nhập cơ sở dữ liệu phpMyadmin # 1046 - Không có cơ sở dữ liệu nào được chọn
- 5. Truyền hoặc chuyển đổi khi truy xuất dữ liệu từ cơ sở dữ liệu?
- 6. cách truy xuất dữ liệu từ cơ sở dữ liệu SQL trong Word 2010?
- 7. API để truy xuất/gửi dữ liệu từ/đến cơ sở dữ liệu
- 8. Cách hibernate truy xuất dữ liệu từ chế độ xem cơ sở dữ liệu hiện tại?
- 9. Truy xuất dữ liệu từ cơ sở dữ liệu trong vòng 7 ngày qua bằng linq
- 10. Truy xuất lược đồ cơ sở dữ liệu
- 11. web.py cơ sở dữ liệu chọn truy cập
- 12. Cách thêm tùy chọn "Tất cả" vào hộp tổ hợp trong WPF có ràng buộc từ Cơ sở dữ liệu
- 13. Truy cập Meteor cơ sở dữ liệu sản xuất
- 14. Ngắt chuỗi được nối tiếp khi truy xuất từ cơ sở dữ liệu
- 15. Truy cập dữ liệu được truy xuất
- 16. Tùy chọn nguồn mở để tạo các biểu mẫu cơ sở dữ liệu
- 17. Hibernate có được Danh sách từ cơ sở dữ liệu
- 18. Cách lấy dữ liệu từ cơ sở dữ liệu Parse.com
- 19. Mongoose: Lược đồ cơ sở dữ liệu được đề xuất
- 20. Cơ sở dữ liệu về độ phức tạp của truy vấn cơ sở dữ liệu
- 21. Android: vấn đề truy xuất bitmap từ cơ sở dữ liệu
- 22. Cách truy vấn cấu hình từ cơ sở dữ liệu trong một MVC tùy chỉnh?
- 23. Làm cách nào để truy cập cơ sở dữ liệu postgresql từ MATLAB mà không có hộp công cụ cơ sở dữ liệu MATLAB?
- 24. Cơ sở dữ liệu xuất MSSQL với dữ liệu
- 25. Chức năng sẽ trả về dữ liệu được truy xuất từ một truy vấn chọn - Oracle
- 26. xiên: lựa chọn cơ sở dữ liệu
- 27. Truy vấn Cơ sở dữ liệu MYSQL Từ MSSQL Windows10
- 28. Truy xuất cấu trúc cây từ cơ sở dữ liệu bằng LINQ
- 29. Làm cách nào để tạo trường django được mã hóa có thể chuyển đổi dữ liệu khi được truy xuất từ cơ sở dữ liệu?
- 30. Hộp thoại bộ chọn tùy chỉnh