Here i've given my rowcommand and row databound code..
can u help me by using this?
protected void grdbroker_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Block")
{
int i = Convert.ToInt32(e.CommandArgument);
int recid = Convert.ToInt32(grdbroker.DataKeys[i].Value);
ViewState["recid"] = recid;
broker.RecID = Convert.ToInt32(ViewState["recid"]);
BAL.fnBlockBroker(broker);
BindBrokerList();
Label lbl=(Label)grdbroker.Rows[i].FindControl("lblrecordstatus");
if(lbl.Text=="Blocked")
{
Session["lnkblocktxt"]="UnBlock";
}
}
else if (e.CommandName == "UnBlock")
{
int i = Convert.ToInt32(e.CommandArgument);
int recid = Convert.ToInt32(grdbroker.DataKeys[i].Value);
ViewState["recid"] = recid;
broker.RecID = Convert.ToInt32(ViewState["recid"]);
BAL.fnUnBlockBroker(broker);
BindBrokerList();
Label lbl=(Label)grdbroker.Rows[i].FindControl("lblrecordstatus");
if(lbl.Text=="Active")
{
Session["lnkblocktxt"] = "Block";
}
}
}
protected void grdbroker_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lnkblock = (LinkButton)e.Row.FindControl("lnkblock");
if (Session["lnkblocktxt"].ToString() == "UnBlock")
{
lnkblock.Text = "UnBlock";
lnkblock.CommandName = "UnBlock";
}
else if (Session["lnkblocktxt"].ToString() == "Block")
{
lnkblock.Text = "Block";
lnkblock.CommandName = "Block";
}
}
}