Greets all,
i have a gridview, image link below
CLICK TO VIEW MY GRIDVIEW
source code
Code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="AccessDataSource1" OnRowDataBound="GridView1_RowDataBound"
ShowFooter="True" CellPadding="4" ForeColor="#333333" GridLines="None"
onselectedindexchanged="GridView1_SelectedIndexChanged" >
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" FooterText="total" />
<asp:TemplateField HeaderText="maths" >
<ItemTemplate>
<asp:TextBox ID="mat" runat="server" Text='<%# Eval("maths").ToString() %>'></asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="mathstotal" runat="server" ></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="science">
<ItemTemplate>
<asp:TextBox ID="sci" runat="server" Text='<%# Eval("science").ToString() %>'></asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="scitotal" runat="server" ></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="computer">
<ItemTemplate>
<asp:TextBox ID="com" runat="server" Text='<%# Eval("computer").ToString() %>'></asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="comtotal" runat="server" ></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="total marks">
<ItemTemplate>
<asp:Label ID="tot" runat="server" Text='<%# Convert.ToInt32(Eval("maths"))+Convert.ToInt32(Eval("science"))+Convert.ToInt32(Eval("computer")) %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="total" runat="server" ></asp:Label>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/Test.accdb"
SelectCommand="SELECT [name], [maths], [science], [computer] FROM [Table1]">
</asp:AccessDataSource>
souce of submit button
Quote:
protected void Button1_Click(object sender, EventArgs e)
{
string connstr = "provider=microsoft.ace.oledb.12.0;data source=c:\\users\\jammy\\documents\\visual studio 2010\\websites\\testing\\app_data\\test.accdb;pers ist security info=true";
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = connstr;
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.InsertCommand = new OleDbCommand();
adapter.InsertCommand.CommandText = "insert into table1(name, maths, science, computer)" + " values( name, maths, science, computer);";
conn.Open();
adapter.InsertCommand.Connection = conn;
adapter.InsertCommand.ExecuteNonQuery();
}
|
the problem is when i am hitting SUBMIT button, i got this error
Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.