GridView Insight ASP 2.0

R

rituchandra0972

Hello,

I am new to ASP 2.0 and have been trying to work with the new gridview.
I am running into road blocks as I try to implement quite a simple
functionality. My functionality is as follows

1. There is a grid that manipulates data through two webservices. This
grid has one field that is displayed as a dropdown in Edit mode. The
dropdown box has only two values that can be hardcoded (as opposed to
populating it from the database). The grid has the Edit,Update,Cancel
buttons and only one row can be updated at a time.

There are two buttons SUBMIT and ADDNEW. The SUBMIT buttons posts the
entire grid to the database in one go (internally one could loop
through and make individual calls to the web-service). The ADDNEW
button adds a row to the bottom of the grid to allow a new record to be
edited.

The way I have started to implment it is

a) Create a class with three functions GetData, InsertData, UpdateData.
This class is wired to an object data source

b)Set the autogeneratecolumns = false
c) Made all the fields into bound columns apart from the column STATUS
which is a template Column. The code looks something like this

<Columns>
<asp:BoundField DataField="Function_ID"
HeaderText="Function_ID" ReadOnly="True"
Visible="False" />
<asp:BoundField DataField="Description"
HeaderText="Function Name" SortExpression="Description" >
<ControlStyle Width="500px" />
<ItemStyle Width="500px" />
</asp:BoundField>
<asp:BoundField DataField="Display_Order"
HeaderText="Display Order" ReadOnly="True"
SortExpression="Display_Order" />

<asp:TemplateField HeaderText="Status"
SortExpression="Status">
<EditItemTemplate>
<asp:DropDownList ID="ddStatus"
DataValueField='<%="Status"%>' runat ="server" Width="100">
<asp:ListItem Value="A">Active</asp:ListItem>

<asp:ListItem Value="I">Inactive</asp:ListItem>

</asp:DropDownList>
</EditItemTemplate>

<Itemtemplate>
<asp:label ID="lblStatus" runat="server"
Text='<%#Bind("StatusDescription")%>' ></asp:label>
</Itemtemplate>

</asp:TemplateField>
<asp:CommandField HeaderText="Edit"
ShowEditButton="True" />
</Columns>


Now let's come to the problems :).

1. The first problem is wiring the drop down field. I am not able to
get the database value pre-selected from the dropdown in edit mode.
Also, I am not sure now to implement this. Do I need to write code in
some event?

2. How does the submit work. Can I submit the entire grid at one time?
If yes, then what's the standard procedure to implement such a
functionality.

As one can see.. this is a pretty simple grid. The only complicating
factor is that the data uses multiple web-services which is more or
less dealt which by having a class.

Is my approach correct? Would appreciate some insights.

Regards,
R
 
R

rituchandra0972

Hello,

I am new to ASP 2.0 and have been trying to work with the new gridview.

I am running into road blocks as I try to implement quite a simple
functionality. My functionality is as follows


1. There is a grid that manipulates data through two webservices. This
grid has one field that is displayed as a dropdown in Edit mode. The
dropdown box has only two values that can be hardcoded (as opposed to
populating it from the database). The grid has the Edit,Update,Cancel
buttons and only one row can be updated at a time.


There are two buttons SUBMIT and ADDNEW. The SUBMIT buttons posts the
entire grid to the database in one go (internally one could loop
through and make individual calls to the web-service). The ADDNEW
button adds a row to the bottom of the grid to allow a new record to be

edited.


The way I have started to implment it is


a) Create a class with three functions GetData, InsertData, UpdateData.

This class is wired to an object data source


b)Set the autogeneratecolumns = false
c) Made all the fields into bound columns apart from the column STATUS
which is a template Column. The code looks something like this


<Columns>
<asp:BoundField DataField="Function_ID"
HeaderText="Function_ID" ReadOnly="True"
Visible="False" />
<asp:BoundField DataField="Description"
HeaderText="Function Name" SortExpression="Description" >
<ControlStyle Width="500px" />
<ItemStyle Width="500px" />
</asp:BoundField>
<asp:BoundField DataField="Display_Order"
HeaderText="Display Order" ReadOnly="True"
SortExpression="Display_Order" />


<asp:TemplateField HeaderText="Status"
SortExpression="Status">
<EditItemTemplate>
<asp:DropDownList ID="ddStatus"
DataValueField='<%="Status"%>' runat ="server" Width="100">
<asp:ListItem Value="A">Active</asp:ListItem>


<asp:ListItem Value="I">Inactive</asp:ListItem>



</asp:DropDownList>
</EditItemTemplate>


<Itemtemplate>
<asp:label ID="lblStatus" runat="server"
Text='<%#Bind("StatusDescription")%>' ></asp:label>
</Itemtemplate>


</asp:TemplateField>
<asp:CommandField HeaderText="Edit"
ShowEditButton="True" />
</Columns>


Now let's come to the problems :).


1. The first problem is wiring the drop down field. I am not able to
get the database value pre-selected from the dropdown in edit mode.
Also, I am not sure now to implement this. Do I need to write code in
some event?


2. How does the submit work. Can I submit the entire grid at one time?
If yes, then what's the standard procedure to implement such a
functionality.


As one can see.. this is a pretty simple grid. The only complicating
factor is that the data uses multiple web-services which is more or
less dealt which by having a class.


Is my approach correct? Would appreciate some insights.


Regards,
R
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top