Last post Mar 26, 2012 09:46 PM by Decker Dong - MSFT
Member
14 Points
122 Posts
Mar 25, 2012 12:13 AM|progammer|LINK
hi for all I have gridview I want to insert throw it
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ID" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" AllowPaging="True" style="font-family: 'Times New Roman', Times, serif; font-size: large; font-weight: 700" ShowFooter="True"> <AlternatingRowStyle BackColor="White" /> <Columns> <asp:BoundField DataField="ID" HeaderText="id" ReadOnly="True" SortExpression="ID" /> <asp:BoundField DataField="Name" HeaderText="name" SortExpression="Name" /> <asp:TemplateField HeaderText="grade"SortExpression="Grade"> <EditItemTemplate> <telerik:RadComboBox ID="RadComboBox1" Runat="server" DataSourceID="SqlDataSource2" DataTextField="GradeDesc" DataValueField="GradeID"> </telerik:RadComboBox> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Grades]"></asp:SqlDataSource> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("Grade") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="per" SortExpression="Per"> <EditItemTemplate> <telerik:RadComboBox ID="rdauthorization" Runat="server"> <Items> <telerik:RadComboBoxItem runat="server" Text="1" Value="1" /> <telerik:RadComboBoxItem runat="server" Text="2" Value="2" /> </Items> </telerik:RadComboBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Eval("PerTypeID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Section" HeaderText="Section" SortExpression="Section" /> <asp:CommandField CancelText="cancel" DeleteText="delete" EditText="edit" InsertText="add" ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="true" NewText="add" /> </Columns> <EditRowStyle BackColor="#2461BF" /> <FooterStyle BackColor="#507CD1" BorderColor="#66FF33" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#EFF3FB" /> <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <SortedAscendingCellStyle BackColor="#F5F7FB" /> <SortedAscendingHeaderStyle BackColor="#6D95E1" /> <SortedDescendingCellStyle BackColor="#E9EBEF" /> <SortedDescendingHeaderStyle BackColor="#4870BE" /> </asp:GridView> any one can modify to me this code to accept insert note in column per I want to make enitial values for combobox thanks
Participant
1852 Points
915 Posts
Mar 25, 2012 01:17 AM|Basquiat|LINK
The GridView doesn't support Insert, you should use a DetailsView or FormView for that.
If you do want to use the GridView, you can look at this workaround http://www.dotnetfunda.com/articles/article180.aspx
All-Star
94130 Points
18109 Posts
Mar 26, 2012 09:46 PM|Decker Dong - MSFT|LINK
Hello progammer:)
GridView doesn't support inserting,So you cannot do that according to the wizard……I mean you can add some textboxes inside the footer of your GridView,with a button beside and do inserting。
See something like this:
http://geekswithblogs.net/casualjim/archive/2005/08/29/51360.aspx
Member
14 Points
122 Posts
insert in gridview
Mar 25, 2012 12:13 AM|progammer|LINK
hi for all I have gridview I want to insert throw it
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ID" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" AllowPaging="True" style="font-family: 'Times New Roman', Times, serif; font-size: large; font-weight: 700" ShowFooter="True"> <AlternatingRowStyle BackColor="White" /> <Columns> <asp:BoundField DataField="ID" HeaderText="id" ReadOnly="True" SortExpression="ID" /> <asp:BoundField DataField="Name" HeaderText="name" SortExpression="Name" /> <asp:TemplateField HeaderText="grade"SortExpression="Grade"> <EditItemTemplate> <telerik:RadComboBox ID="RadComboBox1" Runat="server" DataSourceID="SqlDataSource2" DataTextField="GradeDesc" DataValueField="GradeID"> </telerik:RadComboBox> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Grades]"></asp:SqlDataSource> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("Grade") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="per" SortExpression="Per"> <EditItemTemplate> <telerik:RadComboBox ID="rdauthorization" Runat="server"> <Items> <telerik:RadComboBoxItem runat="server" Text="1" Value="1" /> <telerik:RadComboBoxItem runat="server" Text="2" Value="2" /> </Items> </telerik:RadComboBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Eval("PerTypeID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Section" HeaderText="Section" SortExpression="Section" /> <asp:CommandField CancelText="cancel" DeleteText="delete" EditText="edit" InsertText="add" ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="true" NewText="add" /> </Columns> <EditRowStyle BackColor="#2461BF" /> <FooterStyle BackColor="#507CD1" BorderColor="#66FF33" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#EFF3FB" /> <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <SortedAscendingCellStyle BackColor="#F5F7FB" /> <SortedAscendingHeaderStyle BackColor="#6D95E1" /> <SortedDescendingCellStyle BackColor="#E9EBEF" /> <SortedDescendingHeaderStyle BackColor="#4870BE" /> </asp:GridView> any one can modify to me this code to accept insert note in column per I want to make enitial values for combobox thanks
Participant
1852 Points
915 Posts
Re: insert in gridview
Mar 25, 2012 01:17 AM|Basquiat|LINK
The GridView doesn't support Insert, you should use a DetailsView or FormView for that.
If you do want to use the GridView, you can look at this workaround http://www.dotnetfunda.com/articles/article180.aspx
All-Star
94130 Points
18109 Posts
Re: insert in gridview
Mar 26, 2012 09:46 PM|Decker Dong - MSFT|LINK
Hello progammer:)
GridView doesn't support inserting,So you cannot do that according to the wizard……I mean you can add some textboxes inside the footer of your GridView,with a button beside and do inserting。
See something like this:
http://geekswithblogs.net/casualjim/archive/2005/08/29/51360.aspx