0

Alright so I have a Grid with 17 fields. I have my onrowupdating method, and it works, except for this one value is not getting passed to the method. So when I say e.oldValues I get only 16 not 17.

The problem lies in one of the rows that I converted to a templete field and added a dropdownlist to. When the user clicks edit it turns into a drop down list. When when they click update I want the value of the drop down list to get passed to my method.

This is the code for the col in my gridview that does not work

<asp:TemplateField HeaderText="invld_data_reasn_id" InsertVisible =false  
                SortExpression="invld_data_reasn_id">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("invld_data_reasn_id") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" 
                        DataSourceID="SqlDataSource2" DataTextField="invld_data_reasn_id" 
                        DataValueField="invld_data_reasn_id">
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>

This is the code for the entire grid view:

<asp:GridView ID="GridView1" runat="server" Width="100%" 
        AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
        onselectedindexchanged="GridView1_SelectedIndexChanged" 
        onrowcommand = "GridView1_RowCommand" 
        OnRowUpdating = "GridView1_RowUpdating"
         >
        <Columns>
            
            <asp:BoundField DataField="rview_ind" 
                HeaderText="rview_ind" SortExpression="rview_ind" />
            <asp:BoundField DataField="data_valid_ind" HeaderText="data_valid_ind" 
                SortExpression="data_valid_ind" />
            <asp:TemplateField HeaderText="invld_data_reasn_id" InsertVisible =false  
                SortExpression="invld_data_reasn_id">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("invld_data_reasn_id") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" 
                        DataSourceID="SqlDataSource2" DataTextField="invld_data_reasn_id" 
                        DataValueField="invld_data_reasn_id">
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="circt_nm" SortExpression="circt_nm">
                <EditItemTemplate>
                    <asp:Label ID="TextBox2" runat="server" Text='<%# Bind("circt_nm") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="Label2" runat="server" Text='<%# Bind("circt_nm") %>'
                    commandname = "Circuit" CommandArgument = '<%# Bind("dvc_nm") %>'></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="dvc_nm" SortExpression="dvc_nm">
                <EditItemTemplate>
                    <asp:Label ID="TextBox1" runat="server" Text='<%# Bind("dvc_nm") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="Label1" runat="server" Text='<%# Bind("dvc_nm") %>'
                    commandname = "AssetName" CommandArgument = '<%# Bind("dvc_nm") %>'></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="str_nm" HeaderText="str_nm" 
                SortExpression="str_nm" />
            <asp:BoundField DataField="city_nm" HeaderText="city_nm" 
                SortExpression="city_nm" />
            <asp:BoundField DataField="st_nm" HeaderText="st_nm" 
                SortExpression="st_nm" />
            <asp:BoundField DataField="map_quad_nm" HeaderText="map_quad_nm" 
                SortExpression="map_quad_nm" />
            <asp:BoundField DataField="map_grid_nm" HeaderText="map_grid_nm" 
                SortExpression="map_grid_nm" />
            <asp:BoundField DataField="kva_rateg_qty" HeaderText="kva_rateg_qty" 
                SortExpression="kva_rateg_qty" />
            <asp:BoundField DataField="max_kva_rateg_qty" HeaderText="max_kva_rateg_qty" 
                SortExpression="max_kva_rateg_qty" />
            <asp:BoundField DataField="nmplat_loadg_pctg" HeaderText="nmplat_loadg_pctg" 
                SortExpression="nmplat_loadg_pctg" />
            <asp:BoundField DataField="work_actn_id" HeaderText="work_actn_id" 
                SortExpression="work_actn_id" InsertVisible="False" ReadOnly="True" />
            <asp:BoundField DataField="comnt_txt" HeaderText="comnt_txt" 
                SortExpression="comnt_txt" />
            <asp:BoundField DataField="wrqst_need_ind" HeaderText="wrqst_need_ind" 
                SortExpression="wrqst_need_ind" />
            <asp:BoundField DataField="wrqst_cd" HeaderText="wrqst_cd" 
                SortExpression="wrqst_cd" />
            
            
        </Columns>
    </asp:GridView>

Thanks for any help!!!

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by amar_interface
0

Alright so I have a Grid with 17 fields. I have my onrowupdating method, and it works, except for this one value is not getting passed to the method. So when I say e.oldValues I get only 16 not 17.

The problem lies in one of the rows that I converted to a templete field and added a dropdownlist to. When the user clicks edit it turns into a drop down list. When when they click update I want the value of the drop down list to get passed to my method.

This is the code for the col in my gridview that does not work

<asp:TemplateField HeaderText="invld_data_reasn_id" InsertVisible =false  
                SortExpression="invld_data_reasn_id">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("invld_data_reasn_id") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" 
                        DataSourceID="SqlDataSource2" DataTextField="invld_data_reasn_id" 
                        DataValueField="invld_data_reasn_id">
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>

This is the code for the entire grid view:

<asp:GridView ID="GridView1" runat="server" Width="100%" 
        AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
        onselectedindexchanged="GridView1_SelectedIndexChanged" 
        onrowcommand = "GridView1_RowCommand" 
        OnRowUpdating = "GridView1_RowUpdating"
         >
        <Columns>
            
            <asp:BoundField DataField="rview_ind" 
                HeaderText="rview_ind" SortExpression="rview_ind" />
            <asp:BoundField DataField="data_valid_ind" HeaderText="data_valid_ind" 
                SortExpression="data_valid_ind" />
            <asp:TemplateField HeaderText="invld_data_reasn_id" InsertVisible =false  
                SortExpression="invld_data_reasn_id">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("invld_data_reasn_id") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" 
                        DataSourceID="SqlDataSource2" DataTextField="invld_data_reasn_id" 
                        DataValueField="invld_data_reasn_id">
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="circt_nm" SortExpression="circt_nm">
                <EditItemTemplate>
                    <asp:Label ID="TextBox2" runat="server" Text='<%# Bind("circt_nm") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="Label2" runat="server" Text='<%# Bind("circt_nm") %>'
                    commandname = "Circuit" CommandArgument = '<%# Bind("dvc_nm") %>'></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="dvc_nm" SortExpression="dvc_nm">
                <EditItemTemplate>
                    <asp:Label ID="TextBox1" runat="server" Text='<%# Bind("dvc_nm") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="Label1" runat="server" Text='<%# Bind("dvc_nm") %>'
                    commandname = "AssetName" CommandArgument = '<%# Bind("dvc_nm") %>'></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="str_nm" HeaderText="str_nm" 
                SortExpression="str_nm" />
            <asp:BoundField DataField="city_nm" HeaderText="city_nm" 
                SortExpression="city_nm" />
            <asp:BoundField DataField="st_nm" HeaderText="st_nm" 
                SortExpression="st_nm" />
            <asp:BoundField DataField="map_quad_nm" HeaderText="map_quad_nm" 
                SortExpression="map_quad_nm" />
            <asp:BoundField DataField="map_grid_nm" HeaderText="map_grid_nm" 
                SortExpression="map_grid_nm" />
            <asp:BoundField DataField="kva_rateg_qty" HeaderText="kva_rateg_qty" 
                SortExpression="kva_rateg_qty" />
            <asp:BoundField DataField="max_kva_rateg_qty" HeaderText="max_kva_rateg_qty" 
                SortExpression="max_kva_rateg_qty" />
            <asp:BoundField DataField="nmplat_loadg_pctg" HeaderText="nmplat_loadg_pctg" 
                SortExpression="nmplat_loadg_pctg" />
            <asp:BoundField DataField="work_actn_id" HeaderText="work_actn_id" 
                SortExpression="work_actn_id" InsertVisible="False" ReadOnly="True" />
            <asp:BoundField DataField="comnt_txt" HeaderText="comnt_txt" 
                SortExpression="comnt_txt" />
            <asp:BoundField DataField="wrqst_need_ind" HeaderText="wrqst_need_ind" 
                SortExpression="wrqst_need_ind" />
            <asp:BoundField DataField="wrqst_cd" HeaderText="wrqst_cd" 
                SortExpression="wrqst_cd" />
            
            
        </Columns>
    </asp:GridView>

Thanks for any help!!!

try to use bind instead of eval mehtod

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.