15,911,762 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 Faiz_Khan (Top 20 by date)
Faiz_Khan
23-Jun-12 2:32am
View
Following is the code im using fo navigating Gridview
var SelectedRow = null;
var SelectedRowIndex = null;
var UpperBound = null;
var LowerBound = null;
window.onload = function()
{
//UpperBound = 8;
LowerBound = 0;
SelectedRowIndex = -1;
}
function SelectRow(CurrentRow, RowIndex)
{
if(SelectedRow == CurrentRow || RowIndex > UpperBound || RowIndex < LowerBound)
return;
if(SelectedRow != null)
{
SelectedRow.style.backgroundColor = SelectedRow.originalBackgroundColor;
SelectedRow.style.color = SelectedRow.originalForeColor;
}
if(CurrentRow != null)
{
CurrentRow.originalBackgroundColor = CurrentRow.style.backgroundColor;
CurrentRow.originalForeColor = CurrentRow.style.color;
CurrentRow.style.backgroundColor = '#ff9933';
CurrentRow.style.color = 'Black';
}
SelectedRow = CurrentRow;
SelectedRowIndex = RowIndex;
if(SelectedRow !=null && SelectedRow != '' && SelectedRow != '0')
{
setTimeout("SelectedRow.focus();",0);
}
}
function SelectSibling(e)
{
if(SelectedRow !=null && SelectedRow != '' && SelectedRow != '0')
{
var e = e ? e : window.event;
var KeyCode = e.which ? e.which : e.keyCode;
UpperBound = parseInt(document.getElementById('<%=NoOfRow.ClientID %>').value) - 1;
if(KeyCode == 40)
SelectRow(SelectedRow.nextSibling, SelectedRowIndex + 1);
else if(KeyCode == 38)
SelectRow(SelectedRow.previousSibling, SelectedRowIndex - 1);
else if(KeyCode == 13)
{
var control = '<%=CurRow.ClientID %>';
document.getElementById(control).value = SelectedRowIndex;
document.getElementById('<%= btnAddFromGrid.ClientID %>').click();
}
return false;
}
}
protected void GridView_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate))
{
e.Row.TabIndex = -1;
e.Row.Attributes["onclick"] = string.Format("javascript:SelectRow(this, {0});", e.Row.RowIndex);
e.Row.Attributes["onkeydown"] = "javascript:return SelectSibling(event);";
e.Row.Attributes["onselectstart"] = "javascript:return false;";
}
}
private void FillGridBuyer(string pm)
{
Regex r = new Regex("[0-9]");
if (r.Match(pm).Success)
SqlQry = "SELECT Buyer_Id, Buyer_Name, Contact_Person, Branch FROM Buyer_Master WHERE (Branch = '" + Session["BRANCH"].ToString() + "') and Buyer_code like '%" + pm + "%'";
OF.FillGrid_Without_SP(GVBUY, SqlQry);
NoOfRow.Value = GVBUY.Rows.Count.ToString();
HFNameOfGrid.Value = "GVBUY";
}
Now the Problem is unless i click the Gridview the SelectedRow and SelectedRow.nextSibling will not get.
Faiz_Khan
23-Jun-12 2:21am
View
Deleted
Following is the code im using fo navigating Gridview
var SelectedRow = null;
var SelectedRowIndex = null;
var UpperBound = null;
var LowerBound = null;
window.onload = function()
{
//UpperBound = 8;
LowerBound = 0;
SelectedRowIndex = -1;
}
function SelectRow(CurrentRow, RowIndex)
{
if(SelectedRow == CurrentRow || RowIndex > UpperBound || RowIndex < LowerBound)
return;
if(SelectedRow != null)
{
SelectedRow.style.backgroundColor = SelectedRow.originalBackgroundColor;
SelectedRow.style.color = SelectedRow.originalForeColor;
}
if(CurrentRow != null)
{
CurrentRow.originalBackgroundColor = CurrentRow.style.backgroundColor;
CurrentRow.originalForeColor = CurrentRow.style.color;
CurrentRow.style.backgroundColor = '#ff9933';
CurrentRow.style.color = 'Black';
}
SelectedRow = CurrentRow;
SelectedRowIndex = RowIndex;
if(SelectedRow !=null && SelectedRow != '' && SelectedRow != '0')
{
setTimeout("SelectedRow.focus();",0);
}
}
function SelectSibling(e)
{
if(SelectedRow !=null && SelectedRow != '' && SelectedRow != '0')
{
var e = e ? e : window.event;
var KeyCode = e.which ? e.which : e.keyCode;
UpperBound = parseInt(document.getElementById('<%=NoOfRow.ClientID %>').value) - 1;
if(KeyCode == 40)
SelectRow(SelectedRow.nextSibling, SelectedRowIndex + 1);
else if(KeyCode == 38)
SelectRow(SelectedRow.previousSibling, SelectedRowIndex - 1);
else if(KeyCode == 13)
{
var control = '<%=CurRow.ClientID %>';
document.getElementById(control).value = SelectedRowIndex;
document.getElementById('<%= btnAddFromGrid.ClientID %>').click();
}
return false;
}
}
protected void GridView_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate))
{
e.Row.TabIndex = -1;
e.Row.Attributes["onclick"] = string.Format("javascript:SelectRow(this, {0});", e.Row.RowIndex);
e.Row.Attributes["onkeydown"] = "javascript:return SelectSibling(event);";
e.Row.Attributes["onselectstart"] = "javascript:return false;";
}
}
private void FillGridBuyer(string pm)
{
Regex r = new Regex("[0-9]");
if (pm == "All")
SqlQry = "SELECT Buyer_Id, Buyer_Name, Contact_Person, Branch FROM Buyer_Master WHERE (Branch = '" + Session["BRANCH"].ToString() + "')";
else
if (r.Match(pm).Success)
SqlQry = "SELECT Buyer_Id, Buyer_Name, Contact_Person, Branch FROM Buyer_Master WHERE (Branch = '" + Session["BRANCH"].ToString() + "') and Buyer_code like '%" + pm + "%'";
else
SqlQry = "SELECT Buyer_Id, Buyer_Name, Contact_Person, Branch FROM Buyer_Master WHERE (Branch = '" + Session["BRANCH"].ToString() + "') and Buyer_Name like '%"
Faiz_Khan
18-Jun-12 7:04am
View
I'll pray for ur aircraft pilot’s license, :)
Faiz_Khan
18-Jun-12 6:51am
View
yes its working
thanks a lot dear
Faiz_Khan
18-Jun-12 6:43am
View
k, ..hope it works
Faiz_Khan
18-Jun-12 6:27am
View
its working fine there
Faiz_Khan
18-Jun-12 5:58am
View
exec USP_Delete_Single_PM testTable,id,BO-0001
with hyphen it prints
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '-'.
exec USP_Delete_Single_PM testTable,id,BO0001
without hyphen the print is
DELETE FROM testTable WHERE [id]='BO0001'
Faiz_Khan
18-Jun-12 5:20am
View
SET @DynamicSQL ='DELETE FROM '+ @TableName +' WHERE ' + QUOTENAME(@PM1) +'=''' + @Value1 + ''''
Exec (@DynamicSQL)
as i already said
when i execute with
USP_Delete_Single_PM testTable,id,BO-0001
it gives error as
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '-'.
Its working fine if there is no hyphen in the value
Faiz_Khan
18-Jun-12 2:54am
View
@PM1 is nvarchar(50)
the @Value1 is a string (not a float, neither a datetime)
in database table it is
id nvarchar(50)
name nvarchar(100)
the procedure is for deleting record
i want to delete the row where id = 'BO-0001'
but i have a lot of table so i used a universal procedure to delete a row of a given table(testTable) and field(id)
Faiz_Khan
17-Jun-12 14:22pm
View
Tried to do something like this
<script type="text/javascript" language="javascript">
function FindProduct()
{
if(event.keyCode != 38 && event.keyCode != 39 && event.keyCode != 40 && event.keyCode != 41 && event.keyCode != 8 && event.keyCode != 32)
{
if((event.keyCode > 96 && event.keyCode < 123) || (event.keyCode > 64 && event.keyCode < 91) || (event.keyCode > 47 && event.keyCode < 58))
{
document.getElementById('<%= txtfind.ClientID %>').value =document.getElementById('<%= txtfind.ClientID %>').value + String.fromCharCode(event.keyCode);
event.keyCode=9;
event.cancelBubble=true;
document.getElementById('<%= lnkFindProd.ClientID %>').click();
}
else if (event.keyCode == 13)
{
var control = '<%=CurRow.ClientID %>';
document.getElementById(control).value = "0";
event.keyCode=9;
event.cancelBubble=true;
setCursorPositionToEnd('<%= txtfind.ClientID %>');
document.getElementById('<%= btnAddFromGrid.ClientID %>').click();
}
}
else if(event.keyCode == 8)
{
var strLen = (document.getElementById('<%= txtfind.ClientID %>').value).length;
if(strLen >=1)
{
document.getElementById('<%= txtfind.ClientID %>').value = (document.getElementById('<%= txtfind.ClientID %>').value).slice(0,strLen-1);
event.keyCode=9;
event.cancelBubble=true;
setCursorPositionToEnd('<%= txtfind.ClientID %>');
document.getElementById('<%= lnkFindProd.ClientID %>').click();
}
}
else if(event.keyCode == 40)
{
event.keyCode=9;
event.cancelBubble=true;
document.getElementById('<%=lnkFocus.ClientID %>').click();
}
}
</script>
<table>
<tr>
<td style="width:60%">
<asp:TextBox ID="txtfind" runat="server" Width="99%" onkeydown="FindProduct()" OnTextChanged="txtfind_TextChange" AutoPostBack="true" onfocus="this.style.backgroundColor='#ffccff'" onblur="this.style.backgroundColor='White'">
<asp:LinkButton ID="lnkFindProd" runat="server" OnClick="lnkFindProd_Click">
<asp:LinkButton ID="lnkFocus" runat="server" OnClick="lnkFocus_Click">
</td>
</tr>
</table>
protected void lnkFocus_Click(object sender, EventArgs e)
{
// what to write here to click the gridview and send the focus on it
}
Faiz_Khan
17-Jun-12 14:18pm
View
not working even after quotes
Faiz_Khan
17-Jun-12 14:17pm
View
its not working, pls check urself
Faiz_Khan
17-Jun-12 7:25am
View
:)right
Faiz_Khan
17-Jun-12 5:20am
View
yes, thnx, and pls go through my next question i asked above from OriginalGriff
Faiz_Khan
17-Jun-12 5:14am
View
I have another Question Related to Asp.net 3.5 using C#
I have a textbox at the top of a gridview, when i press a key, the gridview filled with the data related to the text in the textbox.
now i have to click the gridview with mouse to go up and down with arrow keys
I want that when i press down arrow key in the textbox the first row of the gridview is automatically get clicked and the focus goes to the first row(if exist)
Faiz_Khan
17-Jun-12 5:05am
View
@Value1 = BO-0001
as i have already said im executing it with
USP_Delete_Single_PM testTable,id,BO-0001
thnx for the answer
Faiz_Khan
17-Jun-12 5:04am
View
thnx
Faiz_Khan
12-Jun-12 15:06pm
View
I dont want to click the gridview row with mouse so as to get the SelectedRow or SelectedIndex of the gridview, i just want to press the down arrow key focused on the textbox and the first row of the gridview got selected.
im using C#.net 3.5 web Application
Faiz_Khan
11-Jun-12 11:20am
View
@Zoltan, its ASP.NET with C# WebApplication GridView
Faiz_Khan
11-Jun-12 11:19am
View
@Zoltan, its ASP.NET with C# WebApplication GridView
Show More