|
Hi All,
I've a DataSet and I want to display all the data(actually each row in the DataSet) in a list view. I've do the following.
<br />
foreach( DataRow dr in ds.Tables[0].Rows )<br />
{<br />
ListViewItem i = listView1.Items.Add(dr.Table.Rows[0]["ID"].ToString());<br />
<br />
i.SubItems.Add(ds.Tables[0].Rows[0]["Group"].ToString());<br />
i.SubItems.Add(ds.Tables[0].Rows[0]["FirstName"].ToString());<br />
i.SubItems.Add(ds.Tables[0].Rows[0]["LastName"].ToString());<br />
}<br />
ds is the DataSet. My question is, first row display all the time. Means the same row in all. Can someone comment on this.
Thanks a lot
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Solved my-self. Refer the wrong index all the time.
I do the following.
<br />
ListViewItem i = listView1.Items.Add(dr["ID"].ToString());<br />
<br />
i.SubItems.Add(dr["Group"].ToString());<br />
i.SubItems.Add(dr["FirstName"].ToString());<br />
i.SubItems.Add(dr["LastName"].ToString());<br />
Any comments appreciate?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi, would like to check with you guys regarding on ListView.
I done several research on Google for listview but cant find what i wanted.
Example my database have 12 records.
I want to display all 12 data into like a table form.
example
4 rows and 3 column
can anyone show me some sample please. thanks
|
|
|
|
|
It is a bit tricky. However I have done that.
Here I am taking a datatable as my datasource
Objective:
Col1 Col2 Col3
1 2 3
4 5 6
7 8 9
10 11 12
I hope you are asking something similar to this.
Approach:
Step 1:
Create a datatable with 3 columns and 4 rows in .cs file of .aspx page PageLoad event
DataTable dtSource = new DataTable();
#region Data Table Creation
dtSource.Columns.Add("Col1");
dtSource.Columns.Add("Col2");
dtSource.Columns.Add("Col3");
#endregion
#region Add Rows
dtSource.Rows.Add("1", "2", "3");
dtSource.Rows.Add("4", "5", "6");
dtSource.Rows.Add("7", "8", "9");
dtSource.Rows.Add("10", "11", "12");
#endregion
Step 2:
Drag & drop a list view in the .aspx page
<asp:ListView ID="myListView" runat="server">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
</ItemTemplate>
</asp:ListView>
Step 3:
In the code behind, bind the ListView to the datasource(i.e. datatable)
myListView.DataSource = dtSource;
myListView.DataBind();
Step 4:
Create a user control whose .ascx will be
<table>
<tr>
<td>
<asp:Label ID="lblHeaderCol1" runat="server" Text="Col1"></asp:Label>
</td>
<td>
<asp:Label ID="lblHeaderCol2" runat="server" Text="Col2"></asp:Label>
</td>
<td>
<asp:Label ID="lblHeaderCol3" runat="server" Text="Col3"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblContentColumn1" runat="server"></asp:Label>
</td>
<td>
<asp:Label ID="lblContentColumn2" runat="server"></asp:Label>
</td>
<td>
<asp:Label ID="lblContentColumn3" runat="server"></asp:Label>
</td>
</tr>
</table>
Step 5:
In the code behind of the usercontrol(.ascx) expose some properties
#region Properties
public string Col1 { get; set; }
public string Col2 { get; set; }
public string Col3 { get; set; }
public int Counter { get; set; }
#endregion
As you can make out that the properties name are the same as the column names
Step 6:
In the Load event of the UserControl, consume those properties by the respective label controls
protected void Page_Load(object sender, EventArgs e)
{
lblContentColumn1.Text = Col1;
lblContentColumn2.Text = Col2;
lblContentColumn3.Text = Col3;
Counter = Counter + 1;
if (Counter > 1)
{
lblHeaderCol1.Text = lblHeaderCol2.Text = lblHeaderCol3.Text = String.Empty;
}
}
Step 7:
The last step is to call the user control from the .aspx page
Call it from within the item template
<ItemTemplate>
<uc1:MyUserControl ID="MyUserControl1" runat="server" Col1=<%# DataBinder.Eval(Container.DataItem, "Col1")%> Col2=<%# DataBinder.Eval(Container.DataItem, "Col2")%> Col3=<%# DataBinder.Eval(Container.DataItem, "Col3")%> Counter = <%# Container.DataItemIndex %> />
</ItemTemplate>
So the final ListView will look similar to this
<asp:ListView ID="myListView" runat="server">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<uc1:MyUserControl ID="MyUserControl1" runat="server" Col1=<%# DataBinder.Eval(Container.DataItem, "Col1")%> Col2=<%# DataBinder.Eval(Container.DataItem, "Col2")%> Col3=<%# DataBinder.Eval(Container.DataItem, "Col3")%> Counter = <%# Container.DataItemIndex %> />
</ItemTemplate>
</asp:ListView>
What I am doing?
Basically I have exposed the properties from the user control similar to the columns available in the source and have kept a counter.
I am calling the user control from inside the item template ; so each time the user control will be iterated.
But in that case the headers will also be iterated. Inorder to make it unique, the counter is used which will allow the header to be displayed for only the first time.
N.B.~ This is one of the solutions that came in my mind instantly.
If if get a better idea, i will tell you that.
Or else, any kind of improvement from your side, is highly welcome.
Hope this helps.
Niladri Biswas
|
|
|
|
|
Hi, thanks for your reply..
But tts aspx issint it?
my is an .exe application
|
|
|
|
|
Hi man,
You should have mentioned that you are looking for windows based solution and not web based.
Thanks anyways.
Niladri Biswas
|
|
|
|
|
I have an application that crunches lots of data and during the processing, the
application crashes and I get a message that says "fileappend function failed."
I am not a programmer and hope I have the right forum. My apologies if I have
the wrong one...if I do, please direct me to the proper forum.
Any ideas on how to correct this problem will be greatly appreciated.
Pete Brittain
|
|
|
|
|
Hi,
From some distance the tea leaves in your cup told me your disk is full.
Without giving any detail about the program, its purpose, its language, what do you expect?
Go ask the creator of your app I would say.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Thursday, June 4, 2009 4:59 AM
|
|
|
|
|
Zopilote32 wrote: I am not a programmer and hope I have the right forum
You are, by definition, in the wrong forum, and on the wrong site. I would suggest you need to talk to the author of your program, but I do concur with the person who suggested you may be out of hard drive space.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
|
And have you made any attempt or would you like someone to simply write it for you?
only two letters away from being an asset
|
|
|
|
|
Even if you where not bright enough to expect code here, would you at least get some common sense and ask in the asp.net forums? I mean if you're going to break a rule and try and get free work at least address a specialized crowd..
|
|
|
|
|
This[^] has the answer to your question.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Don't delete your messages.
It results in a messy forum.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Believe me, his question made the place messy, too.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Nevertheless, I prefer to keep seeing the original post so I can try and understand how the replies fit (or don't fit) the matter.
I am in favor of making messages undeletable once a reply has been posted; only additive edits should remain possible.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Yeah, that's a good suggestion.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
How do you define an additive edit, though?
What if they need to change some spelling or content?
What if they legitimately need to remove material. I know I've done this when I've reread and realised I've cut and pasted stuff twice.
For a small number of annoying users this is a large inconvenience to everyone else.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
But, what about just removing the ability to delete, so they have to manually delete the text as an edit ? The sort of people we're talking about, wouldn't be smart enough to work out how to do that anyhow.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Now you're using your noggin'
I think simply disallowing deletes until you have a certain experience quotient is the best.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
Chris Maunder wrote: change some spelling or content?
insert the new content in place, leave the old as is.
maybe: allow strike-through
Chris Maunder wrote: legitimately need to remove material
insert a comment [TO BE DELETED] or [IGNORE THIS] or so
Chris Maunder wrote: a large inconvenience to everyone else
if so, limit to new users (first 500 posts)
if they leave their first 500 posts intact, chances are they'll continue to do so.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
hi,
i have installed the crystal report XI but the controls in the toolbox appear disabled.
any idea??
regards,Elie.
dghdfghdfghdfghdgh
|
|
|
|
|
I think you'll find crystal meths causes sligtly less damage to your head. If you had bothered to check for crystal reports here you would have found two pieces of advice:
0. Don't use it.
1. Ask Crystal if you've got a problem.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hi , Crystal report is cause headache ... ( true story )
may be the diabled toolbar at your crystal report , because an active internet connection
or Local area netwrok ,,
thus , try to disable any of those , and re-run crystal report ...
kind regards ...
I know nothing , I know nothing ...
|
|
|
|
|
I'm alreay familiar with Bitmap function: MakeTransparent() which sets one color to be transparent. I would like to go a step further and enable the user to adjust the transparency range around the selected transparency color. I'm currently using the ImageAttributes class for modifying bitmaps and I was hoping to use it for setting the transparency range. I see that there is SetThreshold() and SetColorKey() but I don't know how to use these to set a color range that encompasses hue, saturation and brightness differences.
Any suggestions?
There cannot be a crisis today; my schedule is already full.
|
|
|
|