Hello Guys,
Please find the below code for finding dropdown selected value placed inside gridview control using javascript.
function CheckDropdownValue() {
var grid = document.getElementById("");
var cell;
var isChecked;
isChecked = false;
if (grid.rows.length > 0) {
for (i = 0; i < grid.rows.length; i++) {
cell = grid.rows[i].cells[8];
cell11 = grid.rows[i].cells[0];
if (typeof cell != "undefined") {
for (j = 0; j < cell.childNodes.length; j++) {
// alert(cell.childNodes[j].type);
if (cell.childNodes[j].type == "checkbox") {
if (cell.childNodes[j].checked) {
isChecked = true;var checkbox = cell.childNodes[j];
var ddl = checkbox.parentNode.parentNode.childNodes[0].childNodes[0]
var ddltype = checkbox.parentNode.parentNode.childNodes[0].childNodes[0].type
if (ddl.value == 3) {
alert('Your message');
return false;}
} } } } } }
Thanks,
-Dam
Monday, January 10, 2011
Wednesday, December 29, 2010
Silverlight Tools RTW\Silverlight.2.0_Developer.exe) failed with 0x80070643 - Fatal error during installation
Silverlight Tools RTW\Silverlight.2.0_Developer.exe) failed with 0x80070643 - Fatal error during installation. .
Hi Guys,
If you are getting this error while installing Silverlight development tool for VS 2008, here is the solution
After long struggle, this is what solution I have found, and it worked for me.
1. Install VS 2008 SP1
2. Remove all the Silverlight related software you might have installed with error
a. Silverlight SDK
b. Silver light Runtime tool etc.
3. Then again install Microsoft® Silverlight™ 2 Tools for Visual Studio 2008 SP1 from following link
http://www.microsoft.com/downloads/en/details.aspx?FamilyId=c22d6a7b-546f-4407-8ef6-d60c8ee221ed&displaylang=en
Thanks,
-Dam
Hi Guys,
If you are getting this error while installing Silverlight development tool for VS 2008, here is the solution
After long struggle, this is what solution I have found, and it worked for me.
1. Install VS 2008 SP1
2. Remove all the Silverlight related software you might have installed with error
a. Silverlight SDK
b. Silver light Runtime tool etc.
3. Then again install Microsoft® Silverlight™ 2 Tools for Visual Studio 2008 SP1 from following link
http://www.microsoft.com/downloads/en/details.aspx?FamilyId=c22d6a7b-546f-4407-8ef6-d60c8ee221ed&displaylang=en
Thanks,
-Dam
Wednesday, December 1, 2010
Thursday, October 22, 2009
Working with Microsoft Report Viewer Control in asp.net web application
If you would like to display data in matrix form then Microsoft report viewer control is perfect one for you.
I just show below how you use this control in your application
Create new project – name it as ReportViewer
Add new dataset to your application
Solution-> add new item - > data- Dataset
Go to toolbox as shown below
Drag Table Adapter on Dataset designer
Configure the Data source as shown below. Specify your database
Click next –> then specify your connection string
Click next -> if you have database query specify SQL statements or stored procedure as per your requirements
Click next-> next -> click finish
Now Dataset is configured with data source. Your dataset is ready
Now add rdlc file as shown below to your application.
Solution- Add new Item-> Reporting->Report
Now drag matrix from toolbox on rdlc designer
Now open website data sources (from menu – Data-Show data sources)
Drag fields on matrix as you require displaying data in the matrix
And now save the changes
Now add new web page to your application
Add Microsoft report viewer control on this page
(Drag from Toolbox -> Reporting -> Microsoft Report Viewer)
Select the created rdlc file as your report as shown below
And save your application and run application
Now your data is displaying in matrix format!!!. Change font, background color as you require. enjoy the beauty of this control :) It saves lots of your time for sure....
If you find any issues please write me comment.
Happy coding….
I just show below how you use this control in your application
Create new project – name it as ReportViewer
Add new dataset to your application
Solution-> add new item - > data- Dataset
Go to toolbox as shown below
Drag Table Adapter on Dataset designer
Configure the Data source as shown below. Specify your database
Click next –> then specify your connection string
Click next -> if you have database query specify SQL statements or stored procedure as per your requirements
Click next-> next -> click finish
Now Dataset is configured with data source. Your dataset is ready
Now add rdlc file as shown below to your application.
Solution- Add new Item-> Reporting->Report
Now drag matrix from toolbox on rdlc designer
Now open website data sources (from menu – Data-Show data sources)
Drag fields on matrix as you require displaying data in the matrix
And now save the changes
Now add new web page to your application
Add Microsoft report viewer control on this page
(Drag from Toolbox -> Reporting -> Microsoft Report Viewer)
Select the created rdlc file as your report as shown below
And save your application and run application
Now your data is displaying in matrix format!!!. Change font, background color as you require. enjoy the beauty of this control :) It saves lots of your time for sure....
If you find any issues please write me comment.
Happy coding….
Monday, October 19, 2009
Uploading files to sql server database in asp.net
Guys if u requires storing files in sql server database, then here is the code.
create a datatable as shown in fig.
protected void Button2_Click(object sender, EventArgs e)
{
string cnstng = "Data Source=test;Initial Catalog=testdb;Integrated Security=True";
SqlConnection con = new SqlConnection(cnstng);
string sqlText = "insert into dbo.Attachments (FileName, FileContent,FileSizeInMB,ContentType) values(@FileName ,@FileContent,,FileSizeInMB,ContentType)";
if (FileUpload1.HasFile)
{
HttpPostedFile p_filePosted = FileUpload1.PostedFile;
int length = p_filePosted.ContentLength;
string filePath = p_filePosted.FileName;
string fileName = Path.GetFileName(filePath);
string contentType = p_filePosted.ContentType;
string sizeMB = (length / 1048576).ToString();
int sizeMBIndex = sizeMB.IndexOf(".");
if (sizeMBIndex > 0)
{
sizeMBIndex = sizeMBIndex + 4;
sizeMB = sizeMB.Substring(0, sizeMBIndex);
}
byte[] bytes = new byte[length];
p_filePosted.InputStream.Read(bytes, 0, length);
try
{
con.Open();
SqlCommand cmd = new SqlCommand(sqlText, con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@FileName", fileName);
cmd.Parameters.AddWithValue("@FileContent", bytes);
cmd.Parameters.AddWithValue("@FileSizeInMB", sizeMB);
cmd.Parameters.AddWithValue("@ContentType", contentType);
cmd.ExecuteNonQuery();
}
Catch
{
}
}
}
create a datatable as shown in fig.
Drag a FileUpload control and Button control on Aspx markup .
And on button click event write the following code.protected void Button2_Click(object sender, EventArgs e)
{
string cnstng = "Data Source=test;Initial Catalog=testdb;Integrated Security=True";
SqlConnection con = new SqlConnection(cnstng);
string sqlText = "insert into dbo.Attachments (FileName, FileContent,FileSizeInMB,ContentType) values(@FileName ,@FileContent,,FileSizeInMB,ContentType)";
if (FileUpload1.HasFile)
{
HttpPostedFile p_filePosted = FileUpload1.PostedFile;
int length = p_filePosted.ContentLength;
string filePath = p_filePosted.FileName;
string fileName = Path.GetFileName(filePath);
string contentType = p_filePosted.ContentType;
string sizeMB = (length / 1048576).ToString();
int sizeMBIndex = sizeMB.IndexOf(".");
if (sizeMBIndex > 0)
{
sizeMBIndex = sizeMBIndex + 4;
sizeMB = sizeMB.Substring(0, sizeMBIndex);
}
byte[] bytes = new byte[length];
p_filePosted.InputStream.Read(bytes, 0, length);
try
{
con.Open();
SqlCommand cmd = new SqlCommand(sqlText, con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@FileName", fileName);
cmd.Parameters.AddWithValue("@FileContent", bytes);
cmd.Parameters.AddWithValue("@FileSizeInMB", sizeMB);
cmd.Parameters.AddWithValue("@ContentType", contentType);
cmd.ExecuteNonQuery();
}
Catch
{
}
}
}
Tuesday, October 6, 2009
Double click event for asp.net List Box control
If your requirement is to redirect or other functionalities to be done on double clicking of list box control then here is the solution.
Write following JavaScript method.
function m_lbFallowUp_DoubleClick() {
/* we will change value of this hidden field so that in
page load event we can identify event.
*/
var list = document.getElementById('ctl00_ctl00_ContentPlaceHolder2_m_tpFallowUp_m_lbFallowUp');
for (var i = 0; i < list.options.length; i++) {
if (list.options[i].selected == true) {
document.forms[0].ListBox1Hidden.value = "doubleclicked";
document.forms[0].submit();
}
}
}
place this code in aspx markup
asp:ListBox ID="m_lbFallowUp" Width="400px" Height ="100px" runat="server" ondblclick="m_lbFallowUp_DoubleClick()" asp:ListBox
input type="hidden" name="ListBox1Hidden"
Inside code behind place this code
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["ListBox1Hidden"] != null && (string)Request.Params["ListBox1Hidden"] == "doubleclicked")
{
if (m_lbFallowUp.SelectedItem != null)
{
int fallowUpId = Convert.ToInt32(m_lbFallowUp.SelectedItem.Value);
Response.Redirect("~\\Forms\\CreateFallowUp.aspx?SuggestionId=" + suggestionId + "&FallowUpId=" + fallowUpId );
}
}
}
Write following JavaScript method.
function m_lbFallowUp_DoubleClick() {
/* we will change value of this hidden field so that in
page load event we can identify event.
*/
var list = document.getElementById('ctl00_ctl00_ContentPlaceHolder2_m_tpFallowUp_m_lbFallowUp');
for (var i = 0; i < list.options.length; i++) {
if (list.options[i].selected == true) {
document.forms[0].ListBox1Hidden.value = "doubleclicked";
document.forms[0].submit();
}
}
}
place this code in aspx markup
asp:ListBox ID="m_lbFallowUp" Width="400px" Height ="100px" runat="server" ondblclick="m_lbFallowUp_DoubleClick()" asp:ListBox
input type="hidden" name="ListBox1Hidden"
Inside code behind place this code
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["ListBox1Hidden"] != null && (string)Request.Params["ListBox1Hidden"] == "doubleclicked")
{
if (m_lbFallowUp.SelectedItem != null)
{
int fallowUpId = Convert.ToInt32(m_lbFallowUp.SelectedItem.Value);
Response.Redirect("~\\Forms\\CreateFallowUp.aspx?SuggestionId=" + suggestionId + "&FallowUpId=" + fallowUpId );
}
}
}
Sunday, September 6, 2009
Creating asp.net treeview dynamicaly with sql database for discussion thread.
If you require to display discussion thread where each main topic commented by someone and each comment again reponded by someone and this cycels goes on. Then here is the solution where I have developed same fuctionality using recursive technique. I have used asp.net treeview control where each node is binded with database.
private void CreateParentNode(TreeView p_treeview)
{
try
{
CommentDetails cdetails = new CommentDetails();
DataTable dtComments = cdetails.GetCommentWithoutResponse(suggestionId);//retriving parent node data from database
for (int i = 0; i < dtComments.Rows.Count; i++)
{
DataRow drComments = dtComments.Rows[i];
int commentId = Convert.ToInt32(drComments["commentId"].ToString());
TreeNode root = new TreeNode();
string text = drComments["PostedOn"].ToString() + " " + drComments["StaffName"].ToString();
root.Text = text;
// root.Target = "_blank";
root.NavigateUrl = "~\\Forms\\ViewComment.aspx?SuggestionId=" + suggestionId + "&CommentId=" + commentId ;
p_treeview.Nodes.Add(root);
CreateChildNode(root, commentId); //calling method for creating child node
// p_treeview.CollapseAll();
}
}
catch
{}
}
private void CreateChildNode(TreeNode p_tnode, int p_commentId, int p_discussionType)
{
try
{
CommentDetails cdetails = new CommentDetails();
DataTable dtComments = cdetails.GetResponseByCommentId(suggestionId,p_commentId); //retrieving child nodes data from database
for (int i = 0; i < dtComments.Rows.Count; i++)
{
DataRow drComments = dtComments.Rows[i];
int commentId = Convert.ToInt32(drComments["commentId"].ToString());
TreeNode child = new TreeNode();
string text = drComments["PostedOn"].ToString() + " " + drComments["StaffName"].ToString();
child.Text = text;
//child.Target = "_blank";
child.NavigateUrl = "~\\Forms\\ViewComment.aspx?SuggestionId=" + suggestionId + "&CommentId=" + commentId ;
p_tnode.ChildNodes.Add(child);
// TreeView1.Nodes.Add(p_tnode);
CreateChildNode(child, commentId); //calling this method recursively
}
}
catch
{
}
}
protected void Page_Load(object sender, EventArgs e)
{
if(!IspostBack)
CreateParentNode(TreeView1);
//call this method from page load event // Treeview1 is name of cotrol placed on aspx markup
}
Happy coding…
private void CreateParentNode(TreeView p_treeview)
{
try
{
CommentDetails cdetails = new CommentDetails();
DataTable dtComments = cdetails.GetCommentWithoutResponse(suggestionId);//retriving parent node data from database
for (int i = 0; i < dtComments.Rows.Count; i++)
{
DataRow drComments = dtComments.Rows[i];
int commentId = Convert.ToInt32(drComments["commentId"].ToString());
TreeNode root = new TreeNode();
string text = drComments["PostedOn"].ToString() + " " + drComments["StaffName"].ToString();
root.Text = text;
// root.Target = "_blank";
root.NavigateUrl = "~\\Forms\\ViewComment.aspx?SuggestionId=" + suggestionId + "&CommentId=" + commentId ;
p_treeview.Nodes.Add(root);
CreateChildNode(root, commentId); //calling method for creating child node
// p_treeview.CollapseAll();
}
}
catch
{}
}
private void CreateChildNode(TreeNode p_tnode, int p_commentId, int p_discussionType)
{
try
{
CommentDetails cdetails = new CommentDetails();
DataTable dtComments = cdetails.GetResponseByCommentId(suggestionId,p_commentId); //retrieving child nodes data from database
for (int i = 0; i < dtComments.Rows.Count; i++)
{
DataRow drComments = dtComments.Rows[i];
int commentId = Convert.ToInt32(drComments["commentId"].ToString());
TreeNode child = new TreeNode();
string text = drComments["PostedOn"].ToString() + " " + drComments["StaffName"].ToString();
child.Text = text;
//child.Target = "_blank";
child.NavigateUrl = "~\\Forms\\ViewComment.aspx?SuggestionId=" + suggestionId + "&CommentId=" + commentId ;
p_tnode.ChildNodes.Add(child);
// TreeView1.Nodes.Add(p_tnode);
CreateChildNode(child, commentId); //calling this method recursively
}
}
catch
{
}
}
protected void Page_Load(object sender, EventArgs e)
{
if(!IspostBack)
CreateParentNode(TreeView1);
//call this method from page load event // Treeview1 is name of cotrol placed on aspx markup
}
Happy coding…
Subscribe to:
Posts (Atom)