step 1: i just inserted a dropdownlist value and textbox values in a table and displayed in a gridview.
step 3 : i create update button and i want to update the table with respective itemtemplate id value
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EducationDetails.aspx.cs" Inherits="MangalyamNew1.USER.EducationDetails" %>
<!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>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table align="center" class="style1" width="300px">
<tr>
<td colspan="2">
<asp:Label ID="lblEducHeading" runat="server" Text="Education Details"
Width="300px"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblEducation" runat="server" Text="Education"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlEducationList" runat="server"
DataTextField="EducationDetail" DataValueField="EducationDetail_Id">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblDescrip" runat="server" Text="Description"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtDescription" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="left" colspan="2">
<asp:Button ID="btnEducSubmit" runat="server" Text="Submit" onclick="btnEducSubmit_Click"/>
<asp:Button ID="btnUpdate" runat="server" Text="Update"
onclick="btnUpdate_Click" />
</td>
</tr>
</table>
</div>
<table class="style1">
<tr>
<td>
<asp:GridView ID="grdEducationDetails" runat="server"
AutoGenerateColumns="False" DataKeyNames="EducationDetail_Id"
>
<Columns>
<asp:BoundField DataField="Education" HeaderText="Education" />
<asp:BoundField DataField="EducationDetail" HeaderText="Description" />
<asp:TemplateField HeaderText="Delete" ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server"
CommandArgument='<%# Eval("EducationDetail_Id") %>'
oncommand="ImageButton1_Command" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit" ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"
CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server"
CommandArgument='<%# Eval("EducationDetail_Id") %>'
oncommand="ImageButton2_Command" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</form>
</body>
</html>
code behind page:
protected void ImageButton2_Command(object sender, CommandEventArgs e)
{
int descrip_Id=Convert.ToInt32(e.CommandArgument);
BAL_EducationDetails obj=new BAL_EducationDetails();
obj.ID=descrip_Id;
DataTable dt=BAL_EducationDetails.details(obj);
if(dt.Rows.Count>0)
{
txtDescription.Text=dt.Rows[0]["EducationDetail"].ToString();
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
BAL_EducationDetails obj = new BAL_EducationDetails();
obj.EducationDetails = txtDescription.Text;
obj.ID = Convert.ToInt32(id);
BAL_EducationDetails.update(obj);
}
obj.ID is property that propery is not getting the value..??