.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

GridView.RowCommand Event:-

Posted By: bhanu     Posted Date: November 24, 2010    Points:2   Category :ASP.Net
<asp:LinkButton ID="lnkproductname" runat="server" CommandArgument='<%#Eval("defaultmsg")%>'
CommandName="selectproduct" Text='<%#Eval("defaultmsg") %>'> </asp:LinkButton>

In griview row command iam eriting as:
--------------------------------------------------


protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "selectproduct")
{
txtmsg.Text = Convert.ToString(e.CommandArgument.ToString());
}

}

the value is not displaying in txtmsg textbox..please help me


Responses
Author: Sajid P K             
Posted Date: November 24, 2010     Points: 5   

bhanu,

Can you please post full page aspx code ?

or if ur using Update panel.. Please check both textbox and grid are inside the update panel.


Regards,
Sajid P K

Author: krishana singh             
Posted Date: December 08, 2010     Points: 5   

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EditText")
{


int id = Convert.ToInt32(e.CommandArgument.ToString());
ViewState["userid"] = Convert.ToInt32(e.CommandArgument.ToString());
paneladd.Visible = false;
paneledit.Visible = true;
//panelFlash.Visible = false;
panelshow.Visible = false;
if (con.State == ConnectionState.Closed)
con.Open();
//queary = "SELECT ID,Categoryname,ImageCaption,Image,cost,EntryDate,Status from tblImg where ID=" + id + "";
queary = "SELECT ID,Categoryname,ImageCaption,ImageDescr,Image,costinr,costusd,EntryDate,Status from tblImg1 where ID=" + id + "";
SqlCommand cmd = new SqlCommand(queary, con);
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);


TextBox1.Text = dt.Rows[0][2].ToString();
TextBox2.Text = dt.Rows[0][5].ToString();
TextBox3.Text = dt.Rows[0][3].ToString();
TextBox4.Text = dt.Rows[0][6].ToString();

}
if (e.CommandName == "DeleteText")
{
int id = Convert.ToInt32(e.CommandArgument.ToString());
if (con.State == ConnectionState.Closed)
con.Open();
//string delete = Convert.ToString(new SqlCommand("delete from tblImg where ID=" + id + "", con).ExecuteNonQuery());
string delete = Convert.ToString(new SqlCommand("delete from tblImg1 where ID=" + id + "", con).ExecuteNonQuery());
show();
}
}

Author: krishana singh             
Posted Date: December 08, 2010     Points: 5   

private void show()
{
if (con.State == ConnectionState.Closed)
con.Open();
//queary = "SELECT ID,Categoryname,ImageCaption,Image,cost,EntryDate,Status from tblImg t where Status='1'";
queary = "SELECT ID,Categoryname,ImageCaption,ImageDescr,Image,costinr,costUSD,EntryDate,Status from tblImg1 t where Status='1'";
SqlCommand cmd1 = new SqlCommand(queary, con);
SqlDataReader dr1 = cmd1.ExecuteReader();
DataTable tbl = new DataTable();
tbl.Load(dr1);
dr1.Close();
GridView1.DataSource = tbl;
GridView1.DataBind();

}



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend