Help with research...

liunx

Guest
I have an C# web application that displays records from a database that contain customer data. The application is made up of a Summary table, a Detail table and a couple of associated tables that are linked to the parent record.

My boss just came to me and said "I really like this application however, could you insert a Status field that someone could check in order to make the record invisible"?

What he is drving at is that he wants to be able to give the impression that a record was deleted without actually being deleted.

What I am invisioning is having a Status column in the GridView with a listbox that contains several levels of status such as: Active - Inactive - Closed.

In addition what I would like to have happen is that if a record contains a status of Closed, the record not appear in the Master-Detail report.

Can someone tell me where I might be able to find some doc on how to accomplish this or make a few suggestions?

Thank you very much.

Kind Regards,

TimAre you storeing the status in a db or something? You are just going to need a boolean feild in that case.I usually add a column labeled 'status' and make it an int data type. Then I choose an integer to represent each status. In your case, I would have closed = 0, Inactive = 1 and Active = 2. Then for queries that you only want to return records with certain statuses, you specify the status in your where clause.

Ex:

--### Sql for Master Detail records
--##########################
SELECT
dbo.MyTable.*
FROM
dbo.MyTable
WHERE
dbo.MyTable.Status = 1 OR
dbo.MyTable.Status = 2CStick,

Great. Makes sense however, where I get lost is:

How do I setup my GridView for multipurpose functionality?

In other words, When a user comes to the client page, they are presented with a summary GridView of the Client data. From that GridView they can select a record to obtain detail data.

How do you wire the GridView to allow for a user to mark a record for deletion as well as insert a value for the status?

It sounds like What you were directing me to do is to setup an additional column called status and then place a dropdown listbox in it with the values of Active(1) - Inactive(2) - Closed(0). Then when the use selects a value from the drop down list, the record is marked. But how can you place a ddl inside a BoundField control in a GridView?

Here is my GridView as is:

<asp:GridView ID="GridView1"
runat="server" Font-Names="verdana" Font-Size="X-Small"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="ItemID"
DataSourceID="SqlDataSource1"
CellPadding="4"
ForeColor="#333333"
GridLines="Both"
Width="100%" OnSelectedIndexChanged="Select_New">
<Columns>
<asp:CommandField HeaderText="Action" ShowSelectButton="True" />
<asp:BoundField DataField="Status" HeaderText="Status" />
<asp:BoundField DataField="Cust_Name" HeaderText="Customer Name" SortExpression="Cust_Name" ItemStyle-Width="150" />
<asp:BoundField DataField="Client_Number" HeaderText="Client Number" SortExpression="Client_Number" ItemStyle-Width="80" />
<asp:BoundField DataField="Disp" HeaderText="Disposition" SortExpression="Disp" />
<asp:BoundField DataField="Contact_Date" HeaderText="Contact Date" SortExpression="Contact_Date" ItemStyle-Width="80" />
<asp:BoundField DataField="Reason" HeaderText="Reason" SortExpression="Reason" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<PagerStyle BackColor="#E6E6E6" ForeColor="White" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#E6E6E6" Font-Bold="True" ForeColor="Orange" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>


Thanks for your help.

Sincerely,

TimI ran under the assumption that the client data is comming from a SQL/Access database and that you would add a status column to the database. As for how you would handle changing the status of a particular record, I left that to your imagination.

But, since you are specifically using a datagrid, then maybe I can help with that. You could use a combo box, radio buttons, buttons, etc. That is really up to how you would like to display it and how much effort you are willing to put into it.

I'll tell you how I would handle it. You have three states; active, closed and inactive. I imagine that if you user flags the data as closed, then for all purposes they think that the record is going to be removed from site. An inactive record is in site, however it cannot be modified. And an active record is in site and it can be modified.

So, I would add icons to the end of each row in my datagrid to represent the state. The close icon would be a circle with a line through it, the inactive icon would be a moon, and the active icon would be a sun.

If the state is active, then you'd see the moon and the circle. If the state is inactive, then you'd see the sun and the circle. If the state is closed, you wouldn't see the record at all.

Each time one of the icons is clicked, your application will update the status column for that record in the database. So, if the state is closed then the status column for that record will be changed to 0, Active = 1, Inactive = 2.

Each time a record is modified in the database, you'll want to refetch the client data and databind your datagrid.

Of course, that is just how I would do it. Your application may have different requirements and these requirements will dictate how you display and manage your data.

Hope that helps.CSlick,

I think we both have misunderstood eachother.

I have a graspof the theoretical scenao based upon your last post. :)

What I probably didn't make clear was my environment. I am currently developing this application using asp.net 2.0. The grid I am questioning this technque about is called a GridView and used extensively in VS2005.

My question directly points to whether or not this type of grid will allow for the functionaltiy you have described?
If so, how?

Thanks for all you help.

Sincerely,

Timhi mustang as i read one of your problem, how to place a ddl on a datagrid, am i right?if i am, here is an idea, i actually did it on one of my project, create an extra column and rows to go with that, then if your familiar with creating a control on run time, then you will create a ddl and place it along with the datatgrid.selectedindex which will be incremented with a for statement, i can assist you further if this is one of your problem,
 
Back
Top