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>
<aspropDownList ID="ddStatus"
DataValueField='<%="Status"%>' runat ="server" Width="100">
<asp:ListItem Value="A">Active</asp:ListItem>
<asp:ListItem Value="I">Inactive</asp:ListItem>
</aspropDownList>
</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
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>
<aspropDownList ID="ddStatus"
DataValueField='<%="Status"%>' runat ="server" Width="100">
<asp:ListItem Value="A">Active</asp:ListItem>
<asp:ListItem Value="I">Inactive</asp:ListItem>
</aspropDownList>
</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