|
I dont know why do you need to use DataReader.
Of course you can do that, just need a counter while you read each datarow from the datareader.
Otherwise, I would suggest to get a DataTable from the sqlStatement and use LINQ or by any means to filter out those rows.
datatable.AsEnumerable().Where(datarow=>{
});
Something like this .
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
If your datasource is a collection object, then you can use linq to filter the data source and bind the result with the GridView.
Else,
you can filter your data in RowDataBound event,
if(condition)
e.Row.Visible = false;
hope this will help.
|
|
|
|
|
I have given the following code,but still it is displaying all the rows.
If e.Row.Cells(2).Text <> "" Then
If ((e.Row.Cells(2).Text = e.Row.Cells(2).Text) + 1) Then
e.Row.Visible = False
End If
End If
kissy
|
|
|
|
|
try to debug your code you will find the exact problem.
|
|
|
|
|
Kissy16 wrote: If ((e.Row.Cells(2).Text = e.Row.Cells(2).Text) + 1) Then
Check this line !!
Cheers !
Abhijit Jana | MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Normally you would build that condition into your SQL query statement so that the query only returns those rows you want included in the gridview.
- Dave
|
|
|
|
|
I can't give any condition in my sqlquery so that only desired records can come.
From the display only i have to do,can u give something with gridview which can fulfill my requirement ?
kissy
|
|
|
|
|
Instead of binding the SQL command with the gridview, store the results of the SQL query that match your criteria in a dataset. Then bind the dataset with the gridview. I think this is what Abhishek was suggesting as well.
It would look something like:
DataSet myDataSet = new DataSet();
DataTable myDataTable = myDataTable.Tables.Add();
myDataTable.Columns.Add("ID", typeof(int));
myDataTable.Columns.Add("Foo", typeof(string));
myDataTable.Columns.Add("Bar", typeof(string));
connection.Open();
SqlDataReader dr = cmd.ExecuteReader();
while(dr.Read())
{
if (dr["myCriteria"].ToString() == "this")
{
myDataTable.Rows.Add(
(int)dr["ID"],
dr["Foo"].ToString(),
dr["Bar"].ToString()
);
}
}
dr.Close();
connection.Close();
myGridView.DataSource = myDataSet;
myGridView.BindData();
This could be done more elegantly by using myDataTable.Load(dr) then removing the rows that do not meet your criteria via a LINQ statement. But it should give you an idea of what you are trying to accomplish with a DataSet and get you started...
- Dave
|
|
|
|
|
you nedd to create tp class one will contain the object of other claoss
ClientBasePlanData
ClientBasePlanList : List<ClientBasePlanData>
create the object of ClientBasePlanData fill it and add it into ClientBasePlanList
and later bind it
|
|
|
|
|
i could not understand what u r saying.
I can't give any condition in my sqlquery so that only desired records can come.
From the display only i have to do,i never done the thing u r telling.
can u give some other idea please?
kissy
|
|
|
|
|
Hi, maybe somebody can help me further,
I have a Repeater [Group Repeater], who created a group and in the RepeaterGroup is another Repeater [Skill Repeater], repeats many of the skills of the Group.
So how can I find out whether two groups were already created, to get them and put them in other DIV and add CSS-Style?
should look like this
Click here
|
|
|
|
|
Why dont you increase a counter on ItemDataBound of the repeater ?
I think this would be the easiest way to do this.
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
Currently, there are a total of 7 groups.
I think you should put a counter and if a number is unbarred then DIV to left otherwise DIV to the right?
|
|
|
|
|
Whatever the logic suits you... apply any logic. Just handle the counter from two ItemDataBound events of both the repeaters.
Also make sure you constraint away the ItemTypes for Header and Footer templates.
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
I'm sorry do not understand
|
|
|
|
|
|
I have read it
I mean create outside the function the counter.
if the counter has reached 2, then I'll get the created controls and put them into the new DIV with CSS...
Thats my GroupRepeater ItemdataBound
protected virtual void RepeaterGroup_ItemdataBound(object sender, RepeaterItemEventArgs e)<br />
{<br />
MuMSkillGroup group = (MuMSkillGroup)e.Item.DataItem;<br />
SkillGroupControl currentGoup = (SkillGroupControl)e.Item.FindControl("Skillgroup");<br />
currentGoup.CurrentGroupName = group.SkillGroupName;<br />
currentGoup.IsMatrix = false;<br />
currentGoup.BindAsMyskillpage = true;<br />
}
|
|
|
|
|
if (CountGroup == 6)<br />
{<br />
Repeater getGroupRepeater = (Repeater)sender;<br />
<br />
foreach (RepeaterItem rptItem in getGroupRepeater.Controls)<br />
{<br />
foreach (Control ctrl in rptItem.Controls)<br />
{<br />
if (ctrl is Panel)<br />
{<br />
Panel panelGlobalContainerBox = (Panel)ctrl;<br />
<br />
if (countItemdataBound)<br />
{<br />
panelGlobalContainerBox.CssClass = "content_left";<br />
countItemdataBound = false;<br />
}<br />
else<br />
{<br />
panelGlobalContainerBox.CssClass = "content_right";<br />
countItemdataBound = true;<br />
}<br />
}<br />
}<br />
}<br />
}<br />
THX Abhishek Sur for your Time its solved now
|
|
|
|
|
You are most welcome my friend.
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
Hi Everyone,
I've just finish re-installing VS.NET 2005 and tried the Walkthrough: Displaying Data in a Web Forms Page
I followed exactly as it is that is I tested the connection "Connection Sucessful", test Query "Successfull" but when i run it prompt me with the following error message:
-------------------------------------------------------------------------------------------------
Failed to find or load the registered .Net Framework Data Provider.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Configuration.ConfigurationErrorsException: Failed to find or load the registered .Net Framework Data Provider.
PLease help me in this...
Thanks in Advance
|
|
|
|
|
Well, the problem might be the with the configuration. Check if the config sections are there in web.config.
If that is not the case, I think the provider is not installed properly or corrupt somehow. Might be reinstalling the framework will fix the issue.
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
I have an inline frame which contains a treeview, when a treeview is clicked by the user, it suppose to call a vb method which is sitting in the parent page. How do I do this?
|
|
|
|
|
|
In general, if you want to invoke method from other frame, you need to first access the page using javascript. May be you place your custom AJAX method in page b, and from page a you access the method using window.parent.topframe.document when the name of the top frame is topframe.
http://www.pageresource.com/jscript/jframe1.htm
why dont you remove frames, rather use Masterpage, which is the server side Frame kind of thing. This would help you manage your application more easily.
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
Hi,
I'm trying to include some user credentials for accessing a remote
webservice. The remote location requires that I use Basic
authentication(RFC2617), which means, from browsing around, I need to include
the user name and password in the HTTP header, but I'm not quite sure
how to access the HTTP header that is sent with the webservice soap
message request.
Can anyone help?
Thanks in Advance.
Kunal Tilak
|
|
|
|