Pages

Saturday, November 27, 2010

Row_Command_Edit_Update


----------------------------------------------------------




<ItemTemplate>
<asp:Label ID="lblluserName" runat="server"
Text='<%#Eval("LastName")+","+Eval("FirstName") %> '></asp:Label>
</ItemTemplate>


<ItemTemplate>
<asp:Label ID="lblStatusTerritory" Text='<%#get(Convert.ToBoolean((Eval("IsActive"))))%>'
runat="server"></asp:Label>
</ItemTemplate>



<asp:TemplateField ItemStyle-Width="40px">
<ItemTemplate>
<asp:ImageButton ID="btnEdit" CommandName="Edit" ImageUrl="~/images/edit1.png" ToolTip="Edit record. "
runat="server" Height="15" Width="15" />
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="btnupdate" runat="server" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="btncancel" runat="server" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>

-----------------

protected void grdDirectory_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.ToString().Equals("Update"))
{
DataTable dt = new DataTable();
Hashtable ht = new Hashtable();

LinkButton lnkupdate = (LinkButton)e.CommandSource;
GridViewRow grow = lnkupdate.NamingContainer as GridViewRow;

TextBox txtworkphone = (TextBox)grow.FindControl("txtworkphone");
string strWorkPhone = txtworkphone.Text.ToString().Trim(); ******

Label lblID = (Label)grow.FindControl("lblID");

TextBox txtCompany = (TextBox)grow.FindControl("txtCompany");
string strCompany = txtCompany.Text.ToString().Trim();
}
}

if (e.CommandName.ToString().Equals("Delete"))
{
DataTable dt = new DataTable();
Hashtable ht = new Hashtable();

//LinkButton lnkDelete = (LinkButton)e.CommandSource;
ImageButton imgDelete = (ImageButton)e.CommandSource;
GridViewRow grow = imgDelete.NamingContainer as GridViewRow;

// TextBox txtworkphone = (TextBox)grow.FindControl("txtworkphone");
Label lblID = (Label)grow.FindControl("lblID");

ht.Add("@id", lblID.Text);








0 comments:

Post a Comment

 

CodeAddict.com | Copyright 2009 Tüm Haklar? Sakl?d?r | Free Blogger Templates by GoogleBoy Download Free Wordpress Templates. Unblock through unblock myspace proxy, Hillsongs by Guitar Song Chords