Problem with query string on datalist on next page

Posted by Dotnet4ashu under ASP.NET on 3/16/2013 | Points: 10 | Views : 1872 | Status : [Member] | Replies : 2
Hello Experts,
My problem is very simple ....
how to show value from girdview itemtemplate like i have link button. On next page i have datalist with query string i just want to know how to get id on the next page of datalist (label) on the page load......
but i do just a little code on the gridview This code runs too much fine but my problem is on next page where i could not find value on next page on datalist to show more records

code
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString);
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Session["admins"] as string))
{

}
else
{

}

if (!IsPostBack)
{
admin_enquiry();
}
}
protected void grd_viewEnq_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grd_viewEnq.PageIndex = e.NewPageIndex;
admin_enquiry();

}
public string admin_enquiry()
{
string st = "";
try
{
cmd = new SqlCommand("select id, name,email,mobileno,query from sub_enq order by dt_tim desc", con);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
grd_viewEnq.DataSource = ds;
grd_viewEnq.DataBind();
}
catch (Exception ex)
{
throw ex;
}
finally { cmd.Dispose(); con.Close(); }
return st;
}
protected void grd_viewEnq_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int userid = Convert.ToInt32(grd_viewEnq.DataKeys[e.RowIndex].Values["id"].ToString());

con.Open();
SqlCommand cmd = new SqlCommand("delete from sub_enq where Id=" + userid, con);
int result = cmd.ExecuteNonQuery();
con.Close();
if (result == 1)
{
admin_enquiry();
lblresult.ForeColor = Color.Red;
lblresult.Text = "Details deleted successfully";
}
}
protected void lnk_Viewbtn(object sender, CommandEventArgs e)
{
if (e.CommandArgument != null)
{
Response.Redirect("~/admin/view-more-details.aspx?pid=" + e.CommandArgument.ToString());
}
}
protected void link_view_Edit(object sender, CommandEventArgs e)
{
if (e.CommandArgument != null)
{
Response.Redirect("~/admin/edit-enquiry.aspx?pid=" + e.CommandArgument.ToString());
}
}
ON Next Page
i have datalist ( on datalist i have name,contact number ,description and email)

Please help me on this page how to do best code and find more reocrds on this page...........................

Himanshu Sharma
If you see Dreams then Get Success On Dreams.....



Responses

Posted by: Jayakumars on: 3/17/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

put ur values to session and pass with query string and retrieve there ur values.


Mark as Answer if its helpful to you

Dotnet4ashu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raj.Trivedi on: 3/17/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hello Member,

You will have to store the values in session and then use the Query String to fetch data in such way in your page load in such way

Session["pid"] = Request.QueryString["pid"].ToString();
GetDataListData(Request.QueryString["pid"].ToString());

// Now create a Private function
private void GetCompanies(int pid)
{
// Your fetching code from database.
}



Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved

Dotnet4ashu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response