C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

In hyperlink column how to pass querystring

rated by 0 users
This post has 11 Replies | 3 Followers

Not Ranked
Posts 9
tusharcomtek Posted: Sat, Nov 24 2007 2:32 AM

I have added a new hyperlink column to grid and given datanavigation field and datanavigation url as ~/xyz.aspx?code={0}

where {0} is indicating the datanavigation filed. but i am unable to pass query string

please help

 

.

Not Ranked
Posts 3
rlkery replied on Tue, Nov 27 2007 3:48 PM

You will need to add something like the code I have below in your ItemDataBound event.

 

protected void InventoryGrid_ItemDataBound(object sender, C1ItemEventArgs e)

{

if ((e.Item.ItemType.ToString() != "Header") && (e.Item.ItemType.ToString() != "Footer"))

{

string strTransID = String.Empty,

strInvoiceNmber = String.Empty;

TableCell tempTableCell = e.Item.Cells[18];

strTransID = tempTableCell.Text;

tempTableCell = e.Item.Cells[17];

strInvoiceNmber = tempTableCell.Text;

LinkButton lbReport = (LinkButton)e.Item.Cells[0].Controls[0].FindControl("lbDisplayInvoice");

lbReport.Text = strInvoiceNmber;

lbReport.CausesValidation =
false;if (strInvoiceNmber != "National Account Totals:" && strInvoiceNmber != "Standard Totals:" && strInvoiceNmber != "Maint IO Totals:" && strInvoiceNmber != "ICC Totals:" && strInvoiceNmber != "Grand Totals:")

{

lbReport.Attributes[
"onclick"] = "BLOCKED SCRIPTwindow.open('Display.aspx?ReportIndex=-1&Invoice=" + strTransID + "', '', 'width=600, height=600, menubar=1, toolbar=1, resizable=1');return false";

}

else

{

lbReport.Attributes[
"onclick"] = "BLOCKED SCRIPTreturn false";

}

}

}

Not Ranked
Posts 9

SIR,

I want to pass querystring on field 1 of webgrid with values paasing as

 ~/deails.aspx?a=field1&b=field2

please guide.

 

Top 10 Contributor
Posts 1,102
C1_SergeiS replied on Mon, Dec 24 2007 12:37 AM
Hi,
You should set DataNavigationUrlField to data field name while DataNavigationUrlFormatString should contain format string.
For example:
DataNavigationUrlField  = "CodeField";
DataNavigationUrlFormatString =  "~/xyz.aspx?code={0}";
 
If you did that and it does not work please provide a sample.
 
Regards,
Sergey.
<tusharcomtek> wrote in message news:199995@10.0.1.98...

SIR,

I want to pass querystring on field 1 of webgrid with values paasing as

 ~/deails.aspx?a=field1&b=field2

please guide.

 



http://helpcentral.componentone.com/cs/forums/p/73635/199995.aspx#199995

Not Ranked
Posts 9

sir, Your things are working but only for one field. I wanted to pass two or more fields value then what to do.

 

as stated in my example

~/deails.aspx?a=field1&b=field2

you provided solution for one field only but problem is for more then one field.

 

Tushar Shah

 

Top 10 Contributor
Posts 1,102
You can't specify two fields in C1WebGrid.
You can do it another way, when selecting data from database make a new field that will be a concatenation of two others, like
 
select  (field1 + '&b' + field2) as field3 from ....
 
Then use field3 as DataNavigationUrlField.
Regards,
Sergey.
<tusharcomtek> wrote in message news:200654@10.0.1.98...

sir, Your things are working but only for one field. I wanted to pass two or more fields value then what to do.

 

as stated in my example

~/deails.aspx?a=field1&b=field2

you provided solution for one field only but problem is for more then one field.

 

Tushar Shah

 



http://helpcentral.componentone.com/cs/forums/p/73635/200654.aspx#200654

Top 500 Contributor
Posts 18
mjTaylorh replied on Tue, Mar 11 2008 6:01 PM

I know this is an old post but I am tired of seeing people put information out here that is just totally wrong and dumb. 

Build the hyperlink dynamically in your SELECT query be it a pass through or stored procedure and return it to your grid as a field:

SELECT '<a href=''myPage.aspx?Field1=' + dbField1 + '&Field2=' + dbField2 + '''>I will go to this page with args</a>' As myLink

FROM myTable

ORDER BY whatever

This is setup for a stored procedure using single tick marks for quotes.  If you do a pass through query you will need to modify the tick marks a little with double quotes.

Put the data >> myLink << in a cell in your Grid.  It will be a hyperlink.  When you click on it you will travel.

Top 500 Contributor
Posts 14

 Thanks that is very helpful.  I am also using a link button to allow users to delete the rows.  The problem is that now the customer wants to display all rows but only allow the ones who can (original entry user and Admins) to be able to Edit or Delete the rows.  The edit is easily handled by your suggestion above but I am using the LinkButton and the C1WebGrid.DeletingCommand event to do the deleting.  Now I have the code written to just not delete the row when they are not suppose to but I really would like to be able to not even put the Delete LinkButton up when they cannot delete.  Any great ideas?  I have been looking at the Databind event but it really has nothing to do with the LinkButton logic (at least that I could find). 

 Thanks

Mike

Top 500 Contributor
Posts 18
mjTaylorh replied on Wed, Jun 11 2008 3:53 PM

I'm not exactly sure what you are saying but if I understand you do this: in your select statement create a field for each row that defines WHO can delete this specific record.  Populate the grid row by row with a datareader.  As you are looping through the datareader adding rows to the grid compare the logged on user with the field and see if they are the same. If they are not either do not add the link button or disable it.

while(dr.read())

{

  if (user == dr["authUser"].ToString())

  {

    //add the control or add the control and disable it

  }

}

Top 500 Contributor
Posts 14

 Getting close.  The problem is that I really don't know how to add rows to the grid row by row..  Each row in the grid appear to be a C1Item and there is a collection of Items in the Grid but it is read only.  Any examples of not using databinding to populate the grid?

 

Thanks for your help and the post that started this segment really worked well.

 

Mike

Top 500 Contributor
Posts 14

 I found the answer (I believe) in one of Sergey's old posts.  During the databind event you can modify the controls collection of the individual cells.  This will allow me to either remove the linkbutton or put a blank label in it's place for the rows that individuals are not eligible to delete.

Thanks for all you help

 Mike

Not Ranked
Posts 2
NYMehdi replied on Thu, Jun 12 2008 5:37 AM
DataNavigationUrlField  = "CodeField,secondField";
DataNavigationUrlFormatString =  "~/xyz.aspx?code={0},second{1}";
Page 1 of 1 (12 items) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2010 ComponentOne LLC All Rights Reserved.