Post data from Gridview that is setup by C# code

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a gridview on an aspx page that displays 3 columns: KeyNum, Name, Type of key.
These items are filled by an array from a response object so I had to make a public dataset and tie that to an object datasource on the aspx page. The Key Number needs to be hyperlinked and also post code.
Here is the gridview code
<pre class="prettyprint public DataSet GetKeys()
{

DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt = ds.Tables.Add("Keys");

string installkeys = KeysResponse;
dt.Columns.Add("Key", Type.GetType("System.String"));
dt.Columns.Add("Name", Type.GetType("System.String"));
dt.Columns.Add("Type", Type.GetType("System.String"));

foreach (string k in installkeys)
{
DataRow dr;
dr = dt.NewRow();
dr["Key"] = k.keys;
dr["Name"] = k.name;
dr["Type"] = k.Type;
dt.Rows.Add(dr);
}

return ds;
}[/code]
Here is the Post setup I used to test
<pre class="prettyprint ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "AuthKey=f23232323235a4a5";
postData += "&Permission=View";
postData += "&url=/installation/E310C91C-44B6-4E87-B38D-CA18B37C4C9D";
byte[] data = encoding.GetBytes(postData);


// Prepare web request...
Uri myURL = new Uri("http://server:8080/login");
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(myURL);
myRequest.Method = WebRequestMethods.Http.Post;
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();


// Send the data.
newStream.Write(data, 0, data.Length);
newStream.Close();
Response.Redirect(myURL.ToString()); [/code]
<br/>
Both of these work on their own but I need a way to have that post to be
"URL= /installation/" + k.keys;
and then do this full redirection. Is there a way to make an OnHyperlink click function I guess would be the best question? Thanks in advance for all the help!!


View the full article
 
Back
Top