PC Review


Reply
Thread Tools Rate Thread

Cross Page Postback and Datagrid.

 
 
Jason
Guest
Posts: n/a
 
      7th Jan 2008
On a Datagrid defined as
<asp:datagrid id="dgCountries" width="100%" AutoGenerateColumns="False"
Runat="server" CellSpacing="1" BorderWidth="0px" CellPadding="2"
DataKeyField="code">
<Columns>
<asp:BoundColumn DataField="Code"
HeaderText="Code"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.Code",
"somepage.aspx?countryid={0}") %>'>
<img id="StateImage" runat="server"
src="~/APP_Themes/buttons/Regions.gif" border=0 />
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

the hyperlink provides the row clicked via the Query string. We are getting
rid of the querry string and I need to implement this via CrossPagePostback.
So far I can not figure out how to access which row was selected before it
was passed on the querystring. I am able to access the grid but from there I
am stuck.

the hyperlink above will be changed to something like
<asp:Button Runat=server PostbackUrl="somepage" Id="somecontrol">

Any help would be really appreciated.




 
Reply With Quote
 
 
 
 
Toze
Guest
Posts: n/a
 
      7th Jan 2008
if i understand your problem
you could use a hidden field a javascript function that is called
when you click the hyperlink to set the value of the hidden field with the
value you want

something like

javascript

function setValue(value)
{
var hidden = document.getElementById('<%=hiddenField1.ClientId%>');
hidden.value = value;
}

code-behind
void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

{

if (e.Row.RowType == DataControlRowType.DataRow)

{

Button bt = (Button)e.Row.FindControl("button1");

bt.Attributes.Add("onclick", "setValue(' " + e.Row.RowIndex (or any
value you want to persist + "')");


}

}



"Jason" <(E-Mail Removed)> wrote in message
news:142FCC81-B927-4D62-8837-(E-Mail Removed)...
> On a Datagrid defined as
> <asp:datagrid id="dgCountries" width="100%" AutoGenerateColumns="False"
> Runat="server" CellSpacing="1" BorderWidth="0px" CellPadding="2"
> DataKeyField="code">
> <Columns>
> <asp:BoundColumn DataField="Code"
> HeaderText="Code"></asp:BoundColumn>
> <asp:TemplateColumn>
> <ItemTemplate>
> <asp:HyperLink ID="HyperLink1" runat="server"
> NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.Code",
> "somepage.aspx?countryid={0}") %>'>
> <img id="StateImage" runat="server"
> src="~/APP_Themes/buttons/Regions.gif" border=0 />
> </asp:HyperLink>
> </ItemTemplate>
> </asp:TemplateColumn>
> </Columns>
> </asp:datagrid>
>
> the hyperlink provides the row clicked via the Query string. We are
> getting rid of the querry string and I need to implement this via
> CrossPagePostback. So far I can not figure out how to access which row was
> selected before it was passed on the querystring. I am able to access the
> grid but from there I am stuck.
>
> the hyperlink above will be changed to something like
> <asp:Button Runat=server PostbackUrl="somepage" Id="somecontrol">
>
> Any help would be really appreciated.
>
>
>
>



 
Reply With Quote
 
Jason
Guest
Posts: n/a
 
      7th Jan 2008
Thank you for your input.

Is there a simply way to be doing this. I am new to the CrossPagePostback
and want to make sure I am not overlooking something


"Toze" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> if i understand your problem
> you could use a hidden field a javascript function that is called
> when you click the hyperlink to set the value of the hidden field with the
> value you want
>
> something like
>
> javascript
>
> function setValue(value)
> {
> var hidden = document.getElementById('<%=hiddenField1.ClientId%>');
> hidden.value = value;
> }
>
> code-behind
> void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
>
> {
>
> if (e.Row.RowType == DataControlRowType.DataRow)
>
> {
>
> Button bt = (Button)e.Row.FindControl("button1");
>
> bt.Attributes.Add("onclick", "setValue(' " + e.Row.RowIndex (or
> any value you want to persist + "')");
>
>
> }
>
> }
>
>
>
> "Jason" <(E-Mail Removed)> wrote in message
> news:142FCC81-B927-4D62-8837-(E-Mail Removed)...
>> On a Datagrid defined as
>> <asp:datagrid id="dgCountries" width="100%" AutoGenerateColumns="False"
>> Runat="server" CellSpacing="1" BorderWidth="0px" CellPadding="2"
>> DataKeyField="code">
>> <Columns>
>> <asp:BoundColumn DataField="Code"
>> HeaderText="Code"></asp:BoundColumn>
>> <asp:TemplateColumn>
>> <ItemTemplate>
>> <asp:HyperLink ID="HyperLink1" runat="server"
>> NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.Code",
>> "somepage.aspx?countryid={0}") %>'>
>> <img id="StateImage" runat="server"
>> src="~/APP_Themes/buttons/Regions.gif" border=0 />
>> </asp:HyperLink>
>> </ItemTemplate>
>> </asp:TemplateColumn>
>> </Columns>
>> </asp:datagrid>
>>
>> the hyperlink provides the row clicked via the Query string. We are
>> getting rid of the querry string and I need to implement this via
>> CrossPagePostback. So far I can not figure out how to access which row
>> was selected before it was passed on the querystring. I am able to access
>> the grid but from there I am stuck.
>>
>> the hyperlink above will be changed to something like
>> <asp:Button Runat=server PostbackUrl="somepage" Id="somecontrol">
>>
>> Any help would be really appreciated.
>>
>>
>>
>>

>
>


 
Reply With Quote
 
Toze
Guest
Posts: n/a
 
      7th Jan 2008
well i normally dont use CrossPagePostback ...but that's me
i perfer to user userControls and control myself the data using viewstate
my idea is that full postback of one page on another is something to avoid

sorry my bad english






"Jason" <(E-Mail Removed)> wrote in message
news:0C42FFFA-6416-46BE-B90B-(E-Mail Removed)...
> Thank you for your input.
>
> Is there a simply way to be doing this. I am new to the CrossPagePostback
> and want to make sure I am not overlooking something
>
>
> "Toze" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> if i understand your problem
>> you could use a hidden field a javascript function that is called
>> when you click the hyperlink to set the value of the hidden field with
>> the value you want
>>
>> something like
>>
>> javascript
>>
>> function setValue(value)
>> {
>> var hidden = document.getElementById('<%=hiddenField1.ClientId%>');
>> hidden.value = value;
>> }
>>
>> code-behind
>> void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
>>
>> {
>>
>> if (e.Row.RowType == DataControlRowType.DataRow)
>>
>> {
>>
>> Button bt = (Button)e.Row.FindControl("button1");
>>
>> bt.Attributes.Add("onclick", "setValue(' " + e.Row.RowIndex (or
>> any value you want to persist + "')");
>>
>>
>> }
>>
>> }
>>
>>
>>
>> "Jason" <(E-Mail Removed)> wrote in message
>> news:142FCC81-B927-4D62-8837-(E-Mail Removed)...
>>> On a Datagrid defined as
>>> <asp:datagrid id="dgCountries" width="100%" AutoGenerateColumns="False"
>>> Runat="server" CellSpacing="1" BorderWidth="0px" CellPadding="2"
>>> DataKeyField="code">
>>> <Columns>
>>> <asp:BoundColumn DataField="Code"
>>> HeaderText="Code"></asp:BoundColumn>
>>> <asp:TemplateColumn>
>>> <ItemTemplate>
>>> <asp:HyperLink ID="HyperLink1" runat="server"
>>> NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.Code",
>>> "somepage.aspx?countryid={0}") %>'>
>>> <img id="StateImage" runat="server"
>>> src="~/APP_Themes/buttons/Regions.gif" border=0 />
>>> </asp:HyperLink>
>>> </ItemTemplate>
>>> </asp:TemplateColumn>
>>> </Columns>
>>> </asp:datagrid>
>>>
>>> the hyperlink provides the row clicked via the Query string. We are
>>> getting rid of the querry string and I need to implement this via
>>> CrossPagePostback. So far I can not figure out how to access which row
>>> was selected before it was passed on the querystring. I am able to
>>> access the grid but from there I am stuck.
>>>
>>> the hyperlink above will be changed to something like
>>> <asp:Button Runat=server PostbackUrl="somepage" Id="somecontrol">
>>>
>>> Any help would be really appreciated.
>>>
>>>
>>>
>>>

>>
>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross page postback jazzart@mail.com Microsoft ASP .NET 2 16th Apr 2007 03:38 PM
Cross page postback jazzart@mail.com Microsoft ASP .NET 0 12th Apr 2007 07:08 PM
Page_Load on Source Page Firing on Cross-Page Postback Jason Wilson Microsoft ASP .NET 0 19th Sep 2006 06:59 PM
Cross-Page PostBack, Master page, and GridView issue in ASP.Net 2.0 steve.craver@gmail.com Microsoft ASP .NET 0 22nd May 2006 11:07 PM
view state in previous page using cross page postback bill Microsoft ASP .NET 6 17th Feb 2006 08:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:01 PM.