15,905,504 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Het Upadhyay (Top 6 by date)
Het Upadhyay
27-May-13 9:09am
View
Deleted
protected void Page_Load(object sender, EventArgs e)
{
DropDownList ddl = new DropDownList();
ddl.ID = "ddlChkList";
ListItem lstItem = new ListItem();
ddl.Items.Insert(0, lstItem);
ddl.Width = new Unit(155);
ddl.Attributes.Add("onmousedown", "showdivonClick()");
CheckBoxList chkBxLst = new CheckBoxList();
chkBxLst.ID = "chkLstItem";
chkBxLst.Attributes.Add("onmouseover", "showdiv()");
DataTable dtListItem = GetListItem();
int rowNo = dtListItem.Rows.Count;
string lstValue = string.Empty;
string lstID = string.Empty;
for (int i = 0; i < rowNo - 1; i++)
{
lstValue = dtListItem.Rows[i]["Value"].ToString();
lstID = dtListItem.Rows[i]["ID"].ToString();
lstItem = new ListItem("
" + lstValue + "
", dtListItem.Rows[i]["ID"].ToString());
lstItem.Attributes.Add("onclick", "getSelectedItem('" + lstValue + "','" + i + "','" + lstID + "','listItem');");
chkBxLst.Items.Add(lstItem);
}
System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
div.ID = "divChkList";
div.Controls.Add(chkBxLst);
div.Style.Add("border", "black 1px solid");
div.Style.Add("width", "160px");
div.Style.Add("height", "180px");
div.Style.Add("overflow", "AUTO");
div.Style.Add("display", "none");
phDDLCHK.Controls.Add(ddl);
phDDLCHK.Controls.Add(div);
}
protected void btn_Click(object sender, EventArgs e)
{
string strSelectedItem = string.Empty;
CheckBoxList chk = (CheckBoxList)phDDLCHK.FindControl("chkLstItem");
DropDownList ddl = (DropDownList)Page.FindControl("ddlChkList");
for (int i = 0; i < chk.Items.Count; i++)
{
if (chk.Items[i].Selected)
{
if (strSelectedItem.Length == 0)
{
strSelectedItem = chk.Items[i].Selected.ToString();
}
else
{
strSelectedItem = strSelectedItem + "," + chk.Items[i].Selected.ToString();
}
}
}
ddl.Items.Clear();
ddl.Items.Add(new ListItem(hidList.Value));
lblSelectedItem.Text = strSelectedItem;
}
public DataTable GetListItem()
{
DataTable table = new DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Value", typeof(string));
table.Rows.Add(1, "ListItem1");
table.Rows.Add(2, "ListItem2");
table.Rows.Add(3, "ListItem3");
table.Rows.Add(4, "My ListItem Wraps also");
table.Rows.Add(5, "My New ListItem5");
table.Rows.Add(6, "ListItem6");
table.Rows.Add(7, "ListItem7");
table.Rows.Add(8, "ListItem8");
return table;
}
Het Upadhyay
27-May-13 9:09am
View
Deleted
<script language="javascript" type="text/javascript">
function showdiv() {
document.getElementById("divChkList").style.display = "block";
}
function showdivonClick() {
var objDLL = document.getElementById("divChkList");
if (objDLL.style.display == "block")
objDLL.style.display = "none";
else
objDLL.style.display = "block";
}
function getSelectedItem(lstValue, lstNo, lstID, ctrlType) {
var noItemChecked = 0;
var ddlReport = document.getElementById("ddlChkList");
var selectedItems = "";
var arr = document.getElementById("chkLstItem").getElementsByTagName('input');
var arrlbl = document.getElementById("chkLstItem").getElementsByTagName('label');
var objLstId = document.getElementById('hidList');
for (i = 0; i < arr.length; i++) {
checkbox = arr[i];
if (i == lstNo) {
if (ctrlType == 'anchor') {
if (!checkbox.checked) {
checkbox.checked = true;
}
else {
checkbox.checked = false;
}
}
}
if (checkbox.checked) {
if (selectedItems == "") {
selectedItems = arrlbl[i].innerText;
}
else {
selectedItems = selectedItems + "," + arrlbl[i].innerText;
}
noItemChecked = noItemChecked + 1;
}
}
ddlReport.title = selectedItems;
var Text = ddlReport.options[ddlReport.selectedIndex].text;
if (noItemChecked == 1)
ddlReport.options[ddlReport.selectedIndex].text = lstValue;
else
ddlReport.options[ddlReport.selectedIndex].text = noItemChecked + " Items";
document.getElementById('hidList').value = ddlReport.options[ddlReport.selectedIndex].text;
}
document. önclick = check;
function check(e) {
var target = (e && e.target) || (event && event.srcElement);
var obj = document.getElementById('divChkList');
var obj1 = document.getElementById('ddlChkList');
if (target.id != "alst" && !target.id.match("chkLstItem")) {
if (!(target == obj || target == obj1)) {
obj.style.display = 'none'
}
else if (target == obj || target == obj1) {
if (obj.style.display == 'block') {
obj.style.display = 'block';
}
else {
obj.style.display = 'none';
document.getElementById('ddlChkList').blur();
}
}
}
}
<table>
<tr>
<td valign="top" style="width: 165px">
<asp:PlaceHolder ID="phDDLCHK" runat="server">
</td>
<td valign="top">
<asp:Button ID="btn" runat="server" Text="Get Checked" OnClick="btn_Click" />
</td>
<td valign="top">
<asp:Label ID="lblSelectedItem" runat="server">
</td>
</tr>
</table>
<asp:HiddenField ID="hidList" runat="server" />
</div>
Het Upadhyay
25-May-13 5:02am
View
ok thanx a lot
Het Upadhyay
25-May-13 4:26am
View
but it not working for me. can you pz tell what you have used to call dat function? i have tried using sqldepedency but not working
Het Upadhyay
25-May-13 3:59am
View
Thanx for replay....but trigger will fire at database side how can i change accordingly in my asp.net page?
Het Upadhyay
25-May-13 3:31am
View
Ya it work fine with Ajax but now i want database notify me whenever my table change not whenever whole db change.
Show More