M
Mark Jones
Hi All,
I'm currently having difficulty putting the text from a selected link in a
ButtonColumn from a DataGrid into a cookie. The idea is that a user selects
a group link from this column and is taken to the group page, where the
group link they have just selected is used to populate the page with the
relevant group information from the database. This is done by assigning the
info to a cookie, which is then called on the next page. However, I can't
seem to be able to extract the text information from the selected link in
the DataGrid.
The relevant C# code is as follows:
private void dgGroups_SelectedIndexChanged(object sender, System.EventArgs
e)
{
if (dgGroups.SelectedIndex != -1)
{
string strGroupName = "";
strGroupName += dgGroups.SelectedIndex.ToString();
HttpCookie objNewCookie = new HttpCookie("GroupName");
objNewCookie.Expires = DateTime.Now.AddDays(30);
objNewCookie.Values.Add("groupname", strGroupName);
Response.Cookies.Add(objNewCookie);
Response.Redirect("grouppage.aspx");
}
}
The cookie works fine but I can't deliver the selected text from the
ButtonColumn to the next page, as I can't define the SelectedIndex as Text.
I'm pretty sure I'm missing something out or approaching it the wrong way.
Any help would be much appreciated.
Mark Jones
I'm currently having difficulty putting the text from a selected link in a
ButtonColumn from a DataGrid into a cookie. The idea is that a user selects
a group link from this column and is taken to the group page, where the
group link they have just selected is used to populate the page with the
relevant group information from the database. This is done by assigning the
info to a cookie, which is then called on the next page. However, I can't
seem to be able to extract the text information from the selected link in
the DataGrid.
The relevant C# code is as follows:
private void dgGroups_SelectedIndexChanged(object sender, System.EventArgs
e)
{
if (dgGroups.SelectedIndex != -1)
{
string strGroupName = "";
strGroupName += dgGroups.SelectedIndex.ToString();
HttpCookie objNewCookie = new HttpCookie("GroupName");
objNewCookie.Expires = DateTime.Now.AddDays(30);
objNewCookie.Values.Add("groupname", strGroupName);
Response.Cookies.Add(objNewCookie);
Response.Redirect("grouppage.aspx");
}
}
The cookie works fine but I can't deliver the selected text from the
ButtonColumn to the next page, as I can't define the SelectedIndex as Text.
I'm pretty sure I'm missing something out or approaching it the wrong way.
Any help would be much appreciated.
Mark Jones