| Guest Author: samreen 21 Sep 2012 |
How do i extract the single value of a gridview and display in the different page?
|
| Author: Ravindran 25 Sep 2012 | Member Level: Diamond Points : 1 |
samreen,
You can get cell value using my below resource code and stored in session value or pass as query string to display in other page
http://www.dotnetspider.com/resources/43119-How-get-Grid-view-control-cell-value.aspx
|
| Guest Author: pranjal 22 Oct 2012 |
hello sir/madam
i m working on project where in gridview i have imagebutton when i clic on imagebtn another age is opened where all details of book is shown.pls help i need code
|
| Author: Ravindran 29 Oct 2012 | Member Level: Diamond Points : 5 |
.aspx page Refer below sample code
<asp:GridView ID="GridView1" runat="server" DataKeyNames="eno" AutoGenerateColumns="false" onpageindexchanging="GridView1_PageIndexChanging" PageSize="5" AllowPaging="true" onrowcommand="GridView1_RowCommand"> <Columns> <asp:BoundField DataField="eno" HeaderText="Employee No." /> <asp:BoundField DataField="empname" HeaderText="Employee Name" /> <asp:BoundField DataField="sal" HeaderText="Salary" />
<asp:TemplateField HeaderText="Details"> <ItemTemplate> <asp:ImageButton ID="Image1" runat="Server" CommandName="cmdBind" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" runat="server" CausesValidation="false" ImageUrl="~/images/p1.png" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
.aspx.cs page
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "cmdBind") { LinkButton lb = (LinkButton)e.CommandSource; int index = Convert.ToInt32(lb.CommandArgument); string pkey; //Bind values in the text box of the pop up control pkey = GridView1.Rows[index].Cells[0].Text; Response.Redirect("Page2.aspx?eno=" + pkey + "); //here i have transfer primary key second page taken that query string in second page and get data for that particular record and update it } }
Page2.aspx.cs
using System.Data; using System.Data.SqlClient;
public partial class GridHypher : System.Web.UI.Page { SqlConnection sqlcon = new SqlConnection(@"Server=SQLEXPRESS;database=test;uid=xxxx;pwd=yyyy;"); SqlCommand sqlcmd; SqlDataAdapter da; DataTable dt = new DataTable(); DataTable dt1 = new DataTable();
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string eno; eno = Request.QueryString["eno"]; sqlcon.Open(); sqlcmd = new SqlCommand("select * from emp where eno='" + eno + "'", sqlcon); da = new SqlDataAdapter(sqlcmd); da.Fill(dt); if (dt.Rows.Count > 0) { txteno.Text=dt.Rows[0]["eno"].ToString(); txtempname.Text=dt.Rows[0]["empname"].ToString(); txtsal.Text=dt.Rows[0]["sal"].ToString(); } }
}
}
|
| Guest Author: Sonali 02 Feb 2013 |
can you tell me please how the following will possible using linq to sql i have database table with user id ,name and address, i have connected database to gridview and create name has templete field and display name on linkbutton in grid view and i want that when i clicked that button i want all information of that user to be displayed on label
|
| Guest Author: amitesh 14 Mar 2013 |
In this code i can't edit sid if i want to edit sid , how can i edit sid in it..
|