hm... dont know why failed delivery an email to you.
I have attach my gridview to you. And here is my coding for the button save:
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString);
con.Open();
String insCmd = "Insert into Asset (Notes, Condition) values (@Notes, @Condtion)";
SqlCommand insertUser = new SqlCommand(insCmd, con);
insertUser.Parameters.AddWithValue("@Notes", textbox.Text); //Here my problem. i do not know how to write the coding on this part to save my data into database
insertUser.Parameters.AddWithValue("@Condition", );//Here my problem. i do not know how to write the coding on this part to save my data into database
int Total_Rows = GridView2.Rows.Count;
for (int i = 0; i < Total_Rows; i++)
{
CheckBox Chk_Good = (CheckBox)GridView2.Rows[i].FindControl("chkGood");
CheckBox Chk_Damage = (CheckBox)GridView2.Rows[i].FindControl("chkDamage");
bool Is_Condition_Good = Chk_Good.Checked;
bool is_Condition_Damage = Chk_Damage.Checked;
string Good_value = string.Empty;
if (Is_Condition_Good)
{
Good_value = "Good";
}
string Damage_value = string.Empty;
if (is_Condition_Damage)
{
Damage_value = "Damage";
}
/* Save Record in your Database. */
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Asset_Tracking.aspx.cs" Inherits="Asset_Tracking" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<asp:GridView ID="GridView2" runat="server" CssClass="Grid" Width="90%"
AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333"
GridLines="None">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="ID" visible="false">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Serial Number" SortExpression="SerialNumber">
<ItemTemplate>
<asp:Label ID="lblSerialNumber" runat="server" Text='<%# Eval("SerialNumber") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Asset Model">
<ItemTemplate>
<asp:Label ID="lblAssetModel" runat="server" Text='<%# Eval("AssetModel") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Categories">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource2" DataTextField="CategoryName"
DataValueField="CategoryID">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:RegConnectionString %>"
SelectCommand="SELECT * FROM [Category]"></asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblCategories" runat="server" Text='<%# Eval("Categories") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date Purchased">
<ItemTemplate>
<asp:Label ID="lblDatePurchased" runat="server" Text='<%# Eval("DatePurchased") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date Received">
<ItemTemplate>
<asp:Label ID="lblDateReceived" runat="server" Text='<%# Eval("DateReceived") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Condition">
<ItemTemplate>
<asp:CheckBox ID="chkGood" runat="server" AutoPostBack="True" Text="Good" />
<asp:CheckBox ID="chkDamage" runat="server" AutoPostBack="True" Text="Damage" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Notes">
<ItemTemplate>
<asp:Label ID="lblNotes" runat="server" Text='<%# Eval("Notes") %>'></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
<br />
<asp:Button ID="Button1" runat="server" Text="Save" onclick="Button1_Click" />
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:RegConnectionString %>"
SelectCommand="SELECT * FROM [Asset]"></asp:SqlDataSource>
<br />
</div>
</form>
</body>
</html>