TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dealy
NA
213
0
Gridview filter when typing on a textbox
Aug 22 2016 3:45 AM
Hello,
I have the following code:
<!DOCTYPE html
>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
>
</
title
>
<
style
type
=
"text/css"
>
.auto-style1 {
width: 4px;
}
</
style
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
table
>
<
tr
>
<
td
class
=
"auto-style2"
>
<
asp:Label
ID
=
"lblIDNO"
runat
=
"server"
Text
=
"IDNO:"
>
</
asp:Label
>
</
td
>
<
td
class
=
"auto-style3"
>
<
asp:TextBox
ID
=
"srchIDNO"
runat
=
"server"
>
</
asp:TextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text
=
"Name: "
>
</
asp:Label
>
</
td
>
<
td
>
<
asp:TextBox
ID
=
"srchName"
runat
=
"server"
>
</
asp:TextBox
>
</
td
>
</
tr
>
</
table
>
<
br
/>
<
asp:GridView
ID
=
"gvDisplay"
runat
=
"server"
AutoGenerateColumns
=
"false"
DataSourceID
=
"SqlDataSource1"
DataKeyNames
=
"IDNO"
OnRowDataBound
=
"OnRowDataBound"
EmptyDataText
=
"Δεν υπάρχουν καταχωρημένες αιτήσεις."
>
<
Columns
>
<
asp:BoundField
DataField
=
"IDNO"
HeaderText
=
"IDNO"
ItemStyle-Width
=
"50"
/>
<
asp:BoundField
DataField
=
"CName"
HeaderText
=
"CName"
ItemStyle-Width
=
"80"
/>
<
asp:CommandField
ButtonType
=
"Link"
ShowEditButton
=
"true"
ShowDeleteButton
=
"true"
ItemStyle-Width
=
"100"
/>
</
Columns
>
</
asp:GridView
>
<
br
/>
<
table
>
<
tr
>
<
td
class
=
"auto-style1"
>
IDNO:
<
br
/>
<
asp:TextBox
ID
=
"txtIDNO"
runat
=
"server"
Width
=
"100"
/>
</
td
>
<
td
class
=
"auto-style4"
>
Name:
<
br
/>
<
asp:TextBox
ID
=
"txtName"
runat
=
"server"
Width
=
"200"
/>
</
td
>
<
td
class
=
"auto-style5"
>
<
asp:Button
ID
=
"btnAdd"
runat
=
"server"
Text
=
"Insert"
OnClick
=
"Insert"
Width
=
"90px"
/>
</
td
>
</
tr
>
</
table
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString
=
"<%$ ConnectionStrings:connectionString %>"
DeleteCommand
=
"sprocDelete"
DeleteCommandType
=
"StoredProcedure"
InsertCommand
=
"sprocInsert"
InsertCommandType
=
"StoredProcedure"
SelectCommand
=
"sprocSelect"
SelectCommandType
=
"StoredProcedure"
UpdateCommand
=
"sprocUpdate"
UpdateCommandType
=
"StoredProcedure"
>
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"txtIDNO"
Name
=
"IDNO"
Type
=
"String"
/>
<
asp:ControlParameter
ControlID
=
"txtName"
Name
=
"CName"
Type
=
"String"
/>
</
SelectParameters
>
<
InsertParameters
>
<
asp:ControlParameter
ControlID
=
"txtIDNO"
Name
=
"IDNO"
Type
=
"String"
/>
<
asp:ControlParameter
ControlID
=
"txtName"
Name
=
"CName"
Type
=
"String"
/>
</
InsertParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"IDNO"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"CName"
Type
=
"String"
/>
</
UpdateParameters
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"IDNO"
Type
=
"String"
/>
</
DeleteParameters
>
</
asp:SqlDataSource
>
</
div
>
</
form
>
</
body
>
</
html
>
protected
void
Insert(
object
sender, EventArgs e)
{
SqlDataSource1.Insert();
txtIDNO.Text = String.Empty;
txtName.Text = String.Empty;
}
protected
void
OnRowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType == DataControlRowType.DataRow && gvDisplay.EditIndex != e.Row.RowIndex)
{
(e.Row.Cells[2].Controls[2]
as
LinkButton).Attributes[
"onclick"
] =
"return confirm('Do you want to delete this row?');"
;
}
}
How can I filter the gridview while typing on the textboxes? sprocSelect take parameters the IDNO and Name.
Thank you in advance.
Reply
Answers (
8
)
Real time explanation of Generics
WINCE development