From this Filter GridView based on ASP.Net DropDownList selected value using C#
Can i use edit and update from GridView?
Because i am trying with this link GridView CRUD: Select Insert Edit Update Delete using Single Stored Procedure in ASP.Net.
I am getting error System.ArgumentOutOfRangeException: 'txtDropDownstar' contains an invalid SelectedValue because it is not in the element list. Parameter name: value'
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#0E5297"
BorderStyle="Solid" BorderWidth="5px" CellPadding="3" DataKeyNames="Id,CountryId2" EmptyDataText="لاتوجد بيانات جديده"
ForeColor="Black" ShowFooter="True" Width="100%" OnRowDataBound="GridView1_RowDataBound" OnRowEditing="OnRowEditing"
OnRowCancelingEdit="OnRowCancelingEdit" OnRowUpdating="OnRowUpdating" OnRowDeleting="OnRowDeleting">
<AlternatingRowStyle BackColor="#C7E0F1" />
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="checkAll" runat="server" onclick="checkAll(this);" Checked="True" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" onclick="Check_Click(this)" Checked="True" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="5px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="م">
<ItemTemplate>
<asp:Label ID="lblRowNumber0" runat="server" Text="<%# Container.DataItemIndex + 1 %>" />
</ItemTemplate>
<ControlStyle Width="30px" />
<ItemStyle HorizontalAlign="Center" Width="30px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="الاسم">
<ItemTemplate>
<asp:Label ID="Labname" runat="server" Text='<%# Eval("name") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" Width="250px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="الملف / المدني">
<ItemTemplate>
<asp:Label ID="Labfileid" runat="server" Text='<%# Eval("fileid") %>' ForeColor="Blue"></asp:Label>
<br />
<asp:Label ID="lLabcivilid" runat="server" Text='<%# Eval("civilid") %>'></asp:Label>
</ItemTemplate>
<ControlStyle Width="120px" />
<ItemStyle HorizontalAlign="Center" Width="120px"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="تاريخ الإستلام الادارة">
<ItemTemplate>
<asp:Label ID="lbldateadd" runat="server" Text='<%# Eval("dateadd", "{0:yyyy/MM/dd}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtBoxDate" runat="server" Text='<%# Eval("dateadd","{0:yyyy-MM-dd}") %>' TextMode="Date"></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="120px" />
<ItemStyle Width="120px" HorizontalAlign="Center" ForeColor="Blue"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="تاريخ الإستلام الشؤون الادارية">
<ItemTemplate>
<asp:Label ID="lbldateadd2" runat="server" Text='<%# Eval("dateadd2", "{0:yyyy/MM/dd}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtBoxDate2" runat="server" Text='<%# Eval("dateadd2","{0:yyyy-MM-dd}") %>' TextMode="Date"></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="120px" />
<ItemStyle Width="120px" HorizontalAlign="Center" ForeColor="Blue"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="حالة التقيم">
<EditItemTemplate>
<asp:DropDownList ID="txtDropDownstar" runat="server" SelectedValue='<%# Bind("blockrasme") %>'>
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="section1" Text="ممتاز"></asp:ListItem>
<asp:ListItem Value="section2" Text="جيد جدا"></asp:ListItem>
<asp:ListItem Value="section3" Text="جيد"></asp:ListItem>
<asp:ListItem Value="section4" Text="ضعيف"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabDropDownsta" runat="server" Text='<%# Eval("blockrasme") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="القسم" Visible="False">
<ItemTemplate>
<asp:Label ID="LabCities" runat="server" Text='<%# Eval("Cities") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Link" ShowEditButton="true" ShowDeleteButton="true" HeaderText="تعديل">
<ItemStyle Width="120px" />
</asp:CommandField>
<asp:TemplateField HeaderText="حالة الطلب">
<ItemTemplate>
<asp:Button ID="btnNewRequestsp1" runat="server" CommandArgument="<%# Container.DataItemIndex %>" CssClass="button3"
Font-Bold="True" Height="35px" Width="100px" OnClick="OnDeletesp" Text="معتمد" Visible='<%# Eval("CountryId2").ToString() == "Cancelled" ? true : false %>' />
<asp:Button ID="btnNewRequestsp2" runat="server" CommandArgument="<%# Container.DataItemIndex %>" CssClass="button3"
Font-Bold="True" Height="35px" Width="100px" OnClick="OnCancelsp" Text="غير معتمد" Visible='<%# Eval("CountryId2").ToString() == "return" ? true : false %>' />
</ItemTemplate>
<FooterStyle Width="100px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="ملاحظات">
<ItemTemplate>
<asp:Label ID="Labnoteadd" runat="server" Text='<%# Eval("noteadd") %>' ForeColor="Red"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="Textnoteadd" runat="server" Text='<%# Eval("noteadd") %>' TextMode="MultiLine" Height="100%" Width="100%"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>