Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid Data Passing Problem

Status
Not open for further replies.

spidervenom

Programmer
Mar 8, 2003
19
0
0
US
Hi,

I am pretty new to ASP.NET. I am working on a Message Approval project using VB.NET. I have created two datagrids and some data are stored

Waiting for Approval datagrid:
Approval ID Date Name Message
Approve 1 1/28/2004 testname testmessage
Approve 2 1/28/2004 testname1 testmessage1

Approved Message datagrid
ID Date Name Message

Approve is a hyperlink that I stored in the database(Access) as a string: <a href=&quot;login.aspx&quot;>Approve</a>

and I would like to do the followings:

1. When Approve is clicked, it will direct the user to a login page where user needs to enter a user name and a password in order for the specific message to be approved. I tried a few time but it doesn't succeed. How to pass a specific message to approve (i.e when user click on the Approve beside ID=1, how can I make it approve the message where ID = 1 but not ID=2)

2. Upon successful login(i.e message approved), that specific message will move from the Waiting for Approval datagrid to the Approved Message datagrid

Can anyone help me with this problem?

Thanks in advance for the help!



 
when you return the column that stores the web link you can append a querystring variable on it such as
<a href=&quot;Login.aspx?ID=1&Appr=1&quot;>Approve</> then on your login page after logged in if the QueryString &quot;Appr&quot; is equal to 1 then do a procedure to update the item to being approved.

DLC
 
What you want to do is pass an ID field to the next page. A common way is to use a query-string value - i.e.
Code:
page.aspx?id=1234

Then in &quot;page.aspx&quot;, you can simply grab the value using the Request.QueryString collection...
Code:
 myID = Request.QueryString(&quot;id&quot;)

Using a DataGrid makes this process of contructing the url for each record painfully easy - simply use a HyperLinkColumn like this
Code:
<DataGrid>
 <Columns>
  <HyperLinkColumn Text=&quot;Approve&quot; UrlField=&quot;MessageID&quot; UrlFormatString=&quot;Login.aspx?id={0}&quot; />
 </Columns>
<DataGrid>

Hopegully that is enough to get you going!

 
First, thank you very much to both of you for the help, I almost get it done.

Just one more question. I have the following code when the login button is click:

Sub LoginBtn_Click(Sender As Object, E As EventArgs)

If Page.IsValid Then
Dim userDS As New System.Data.DataSet
userDS = GetUser(UserName.Text, UserPass.Text)
If userDS.Tables(0).Rows.Count = 1 Then
Dim myID as Integer = Int32.Parse(Request.QueryString(&quot;ID&quot;))

'Get msg relative to ID
GetRelatedMsg(myID)



'Insert approve msg into the Approved message table

??????????? How do i pass the Dataset returned from the GetRelatedMsg() into the
an insert statement??????????????



Response.Redirect(&quot;mainpage.aspx&quot;)
FormsAuthentication.RedirectFromLoginPage(UserName.Text, false)
Else
LoginMsg.Text = &quot;Invalid Password! Please try again&quot;
End If
End If

End Sub

GetRelatedMsg Function:
Function GetRelatedMsg(ByVal ID As Integer) As System.Data.DataSet

it will return date, name, subject, and details from the database


ApprovedMsg Fucntion (this is where the dataset need to pass in):

Function GetApproveTSN(ByVal [date] As Date, ByVal name As String, ByVal subject As String, ByVal details As String) As Integer

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top