Click here to Skip to main content
15,888,968 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Registry access Pin
siva45529-Jan-09 21:30
siva45529-Jan-09 21:30 
AnswerRe: Registry access Pin
Ashutosh Phoujdar29-Jan-09 22:14
Ashutosh Phoujdar29-Jan-09 22:14 
GeneralRe: Registry access [modified] Pin
siva45529-Jan-09 22:24
siva45529-Jan-09 22:24 
GeneralRe: Registry access Pin
Ashutosh Phoujdar29-Jan-09 23:13
Ashutosh Phoujdar29-Jan-09 23:13 
GeneralRe: Registry access Pin
siva45529-Jan-09 23:55
siva45529-Jan-09 23:55 
QuestionHow to access a control of a Master Page? Pin
zinzil29-Jan-09 18:22
zinzil29-Jan-09 18:22 
AnswerRe: How to access a control of a Master Page? Pin
Spunky Coder29-Jan-09 18:56
Spunky Coder29-Jan-09 18:56 
QuestionCreating a Search Control Pin
scotchy2hotty2k229-Jan-09 18:19
scotchy2hotty2k229-Jan-09 18:19 
Hi all I want to create a very generic search control which i can use it on any page.so as to search the data from the table provided by user,list of columns and the sql will be dynamically created depending on textbox id and there respective values.
Please Suggest how do i create a server control so that i can use it on any page which will be either return dynamic sql or datasource for binding with gridview.





protected void Button1_Click(object sender, EventArgs e)
{
string conn=server=localhost;database=MyData;uid=sa;password=password";
SqlConnection sconn = new SqlConnection();
sconn.ConnectionString = conn;
ArrayList ar = new ArrayList();
ArrayList ar1 = new ArrayList();
foreach (Control c in Panel1.Controls)
{

Type t = c.GetType();
string id;
string value;
string name = t.Name;
TextBox t1 = null;
if (name.Equals("TextBox"))
{
id = c.ClientID;
ar.Add(id);
t1 = (TextBox)c;
if (t1.Text.Length>0)
{
value = t1.Text;
}
else
{
value = "%";
}
ar1.Add(value);

}
}


bool lbHasWhere = false;
StringBuilder loBuffer = new StringBuilder();

loBuffer.Append("Select '"+columns+"' From '" + tablename+ "'");



for (int k = 0; k < ar.Count; k++)
{

if (lbHasWhere)
loBuffer.Append(" And ");
else
{
loBuffer.Append(" Where ");
lbHasWhere = true;
}
loBuffer.Append("" + ar[k] + " like '" + ar1[k] + "'");
}


SqlCommand scomm = new SqlCommand();
scomm.CommandText = loBuffer.ToString();
scomm.Connection = sconn;
sconn.Open();

SqlDataReader sdr = scomm.ExecuteReader();
GridView1.DataSource = sdr;
GridView1.DataBind();
sconn.Close();
}
}
QuestionClick Once - Publish.html - not recognizing framework 2.2.30729 Pin
N.Surendra Prasad29-Jan-09 17:58
N.Surendra Prasad29-Jan-09 17:58 
QuestionHiding WebForm in ASP.NET Pin
siddisagar29-Jan-09 17:05
siddisagar29-Jan-09 17:05 
AnswerRe: Hiding WebForm in ASP.NET Pin
N a v a n e e t h29-Jan-09 17:42
N a v a n e e t h29-Jan-09 17:42 
QuestionHow to make a post to page with href url Pin
papy-boom29-Jan-09 13:22
papy-boom29-Jan-09 13:22 
AnswerRe: How to make a post to page with href url Pin
Tad McClellan29-Jan-09 17:12
professionalTad McClellan29-Jan-09 17:12 
QuestionApplication_End () problem Pin
sana1729-Jan-09 9:53
sana1729-Jan-09 9:53 
AnswerRe: Application_End () problem Pin
Steven James Gray29-Jan-09 10:37
Steven James Gray29-Jan-09 10:37 
AnswerRe: Application_End () problem Pin
Tad McClellan29-Jan-09 11:01
professionalTad McClellan29-Jan-09 11:01 
GeneralRe: Application_End () problem Pin
sana1729-Jan-09 11:12
sana1729-Jan-09 11:12 
AnswerRe: Application_End () problem Pin
N a v a n e e t h29-Jan-09 15:01
N a v a n e e t h29-Jan-09 15:01 
Questionchanging property of some other form's control? Pin
Tarun.Suneja29-Jan-09 7:38
Tarun.Suneja29-Jan-09 7:38 
AnswerRe: changing property of some other form's control? Pin
ToddHileHoffer29-Jan-09 7:48
ToddHileHoffer29-Jan-09 7:48 
AnswerRe: changing property of some other form's control? Pin
Tad McClellan29-Jan-09 11:04
professionalTad McClellan29-Jan-09 11:04 
Question[newbie] Validating a date Pin
jon-8029-Jan-09 6:53
professionaljon-8029-Jan-09 6:53 
AnswerRe: [newbie] Validating a date Pin
N a v a n e e t h29-Jan-09 7:26
N a v a n e e t h29-Jan-09 7:26 
AnswerRe: [newbie] Validating a date Pin
ToddHileHoffer29-Jan-09 7:53
ToddHileHoffer29-Jan-09 7:53 
Questionone webform to other Pin
Tarun.Suneja29-Jan-09 6:33
Tarun.Suneja29-Jan-09 6:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.