|
Hi,
I have a generic list with the following collection
Name
Age
ID
Count
Mark
How can i remove the items with age=10
Thankyou
YPKI
|
|
|
|
|
|
How about
list.RemoveAll(f => f.Age == 10);
|
|
|
|
|
string connection2 = ConfigurationManager.AppSettings["conn"];
OleDbConnection con2 = new OleDbConnection(connection2);
string connectionString = ConfigurationManager.AppSettings["conn"];
if(DropDownList1.SelectedItem.ToString()=="ALL")
{
string query = "select * from appointment where DATE > @StartDate and DATE < @EndDate ";
}
else
{
string query = "select * from appointment where DATE > @StartDate and DATE < @EndDate and DOCTOR_NAME='"+DropDownList1.SelectedItem.ToString()+"'";
}
// wrap the connection and command in using block to avoid resource leaks.
using (OleDbConnection connection = new OleDbConnection(connectionString))
using (OleDbCommand command = new OleDbCommand(query, connection))
{
command.Parameters.AddWithValue("@StartDate", sel.ToShortDateString());
command.Parameters.AddWithValue("@EndDate", tmp.ToShortDateString());
connection.Open();
// using a reader. You don't need a dataset as you are not persisting it in memory
using (OleDbDataReader reader = command.ExecuteReader())
{
GridView1.DataSource = reader;
GridView1.DataBind();
}
connection.Close();
}
}
its showing an error like
Error 1 The name 'query' does not exist in the current context C:\Users\Ankit\Documents\Visual Studio 2005\WebSites\WebSite1\Default.aspx.cs 53 56 C:\...\WebSite1\
can anyone help
|
|
|
|
|
|
using (OleDbCommand command = new OleDbCommand(query, connection))
in dis line
|
|
|
|
|
Try This:
<big>string query ;</big>
if(DropDownList1.SelectedItem.ToString()=="ALL")
{
string query = "select * from appointment where DATE > @StartDate and DATE < @EndDate ";
}
else
{
string query = "select * from appointment where DATE > @StartDate and DATE < @EndDate and DOCTOR_NAME='"+DropDownList1.SelectedItem.ToString()+"'";
}
|
|
|
|
|
|
I think it's because you are declaring the string variable, query, inside the If statement, therefore it is out of scope. Declare the variable at the top with the other declarations.
|
|
|
|
|
So how come you're smarty enough to use params for StartDate and EndDate but not for the doctor name?
|
|
|
|
|
Hi,
I have a gridview with autogenerated fields, 2 template fields, 1 command field. Now, I want to hide one of the columns in a gridview .
I have a code written in rowdatabound
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[2].Visible = false;
}
this code works well when I have not introduced allow paging=true.
but when I have a page indexing property my code for pageindexingchanging is:
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridview1.pageindex=e.newpageindex;
fillgrid();
}
where fillgrid is a function which is simply binding data coming from data base in gridview.
when I add page indexing to my gridview I get an error:
Specified argument was out of the range of valid values.
Parameter name: index
on this line:
e.Row.Cells[2].Visible = false;
any help shall be appreciated.
|
|
|
|
|
Instead of
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[2].Visible = false;
}
try
protected void GridView1_DataBound(object sender, EventArgs e)
{
e.Row.Cells[2].Visible = false;
}
|
|
|
|
|
Hi Meetu,
Meetu Choudhary wrote: protected void GridView1_DataBound(object sender, EventArgs e)
{
e.Row.Cells[2].Visible = false;
}
I tried but there is an error that it cannot access 'row' in the gridview1_databound event
|
|
|
|
|
Oh Sorry I posted Wrong Code.
Try This
protected void GridView1_DataBound(object sender, EventArgs e)<br />
{<br />
GridView1.Columns[0].Visible = false;<br />
}
|
|
|
|
|
Thanks for the code; it worked.
how can I add to your reputation from where?
|
|
|
|
|
Your Most Welcome. You can mark the answer as good answer or rate it..
|
|
|
|
|
|
Hi,
shouldn't the tags be named <fieldname> and <fieldvalue>? The server is throwing an error because you didn't set the arrays correctly.
Regards
Sebastian
|
|
|
|
|
Hi Sebastian,
i have set all the array Correctly like
object[] _fieldNames = new object[11];
object[] _fieldValues = new object[11];
_fieldNames[0] = "Set";
_fieldValues[0] = 1;
Output = call.Ex("A", _fieldNames, _fieldValues);
Can u tell me where i am wrong
thanks
prabhakar dwivedi
|
|
|
|
|
Well it seems that the client "call" you are using doesn't generate the correct soap-request. Look at the wsdl of the webservice and compare if the soap-request matches the wsdl. If not, the problem is the "call" object. How did you created it?
|
|
|
|
|
Hi,
I want to search a database for some documents and then present the search results from my web application.
I thought about using a GridView but that will display strictly in columns/rows. What I want is to display several rows for each result like this:
----------------------------------------------
Search Result #1
This is a bit of text describing the document
This is the actual URL of the document
Search Result #2
This is a bit of text describing the document
This is the actual URL of the document
etc.
-----------------------------------------------
Can anyone suggest a good approach? I can't use GridView for this and TextArea won't work either will it? Any other ideas?
|
|
|
|
|
Maybe a Repeater control?
|
|
|
|
|
You may have a look at Repeater [^]control.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
i have created a dataset named dataset1.xsd and a datatable my_dt with the same fields as in my database.i have taken a crystal report viewer in my webform.and also added a crystal report to my website and binded it to the above dataset.
i now want to write some queries and acoordingly display the datas from the databse in crystal reort.can anyone help me with the coding.it may seem to be a direct question but i have tried a lot.gone through different sites but coulnt get it.
am using access as ma database
|
|
|
|
|
in your case try to create a stored procedure attach it with crystal report and make sure that stored prcedure accept parametors..
pass parametors from C# or vb to crystal report in order to filter or display data what every you want..
Government Dyal Singh College Lahore.
|
|
|
|