Question

I am working on ASP.net 4.0 integrated with Oracle 10.2.0.4

This is my code for GridView and its SqlDatasource

<asp:GridView ID="gvRegNumber" runat="server" AutoGenerateColumns="False" DataSourceID="DsRegNumberGrid"
            Width="100%" AllowPaging="True" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
            BorderWidth="3px" CellSpacing="2" ForeColor="Black" PageSize="3" 
            CssClass="mGrid" onrowcommand="gvRegNumber_RowCommand" >
            <Columns>
                <asp:BoundField DataField="Registration No." HeaderText="Registration No." SortExpression="Registration No." />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Make" HeaderText="Make" SortExpression="Make" />
                <asp:BoundField DataField="Model" HeaderText="Model" SortExpression="Model" />
                <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
                <asp:BoundField DataField="From Date" HeaderText="From Date" SortExpression="From Date" />
                <asp:BoundField DataField="To Date" HeaderText="To Date" SortExpression="To Date" />
                         <asp:TemplateField>
                <EditItemTemplate>
                    <asp:ImageButton ID="imgbtnUpdate" CommandName="Update" runat="server" ImageUrl="~/Themes/Icons/edit_icon.png"
                        ToolTip="Update" Height="20px" Width="20px" />
                </EditItemTemplate>
                <HeaderTemplate>
                    <asp:Label ID="Edit" Text="Edit" runat="server"></asp:Label>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:ImageButton ID="EditRow" CssClass="mGrid-edit" ImageUrl="~/Themes/Icons/edit_icon.png"
                        runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <HeaderTemplate>
                    <asp:Label ID="Delete" Text="Edit" runat="server"></asp:Label>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:ImageButton ID="DeleteRow" CssClass="mGrid-delete" ImageUrl="~/Themes/Icons/delete_icon.png"
                        runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
            </Columns>

        </asp:GridView>
        <asp:SqlDataSource ID="DsRegNumberGrid" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT &quot;fkEnumerationId&quot; AS &quot;Registration No.&quot;, &quot;Text&quot; AS &quot;Name&quot;, &quot;AdditionalValueText&quot; AS &quot;Make&quot;, &quot;AdditionalValue&quot; AS &quot;Model&quot;, &quot;IsActive&quot; AS &quot;Status&quot;, &quot;CreatedOn&quot; AS &quot;From Date&quot;, &quot;LastUpdatedOn&quot; AS &quot

;To Date&quot; FROM &quot;EnumerationValue&quot;">
    </asp:SqlDataSource>

I just want to have separate Datasource for separate columns in my grid. Is that possible? If so, how?

Thanks in advance.

Was it helpful?

Solution

you can do this in your SP

select en1.text as 'Country', en2.text as 'City',en3.text as 'Region'  from
EnumValue en1, EnumValue en2, EnumValue en3
where en1.id = en2.[fkEnumeration] and en3.[fkEnumeration] = en2.id  and 
en1.id='yourid' ;

OTHER TIPS

try this in your Stored Procdure:

declare @temp_tbl TABLE (North varchar(10), South varchar(10))
insert into @temp_tbl TABLE(North)
select Text from table_name where Text='North'
insert into @temp_tbl(South)
select Text from table_name where Text='South'

This is what I understood from your requirement "you want a grid that will dynamically change its column values or you have to bind the grid dynamically not just by DB incoming data." In that case, on page load event, you can create a table dynamically and add whatever controls you want. In that case you can add events too (textChange, selectedindexchange etc). Suppose you have 10 users and for each user you have to get the address. So you may have first column for country drop down, in second column you may have a state drop down and in third column you may have a city drop down and all are run-time linked to each other. If you have such requirement then I will suggest you to go for dynamic table generation instead of grid.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top