I have a WebGrid that has a "Row_ID" field. The field is a hyperlink. When the user clicks on this field, I want it to open the WebDialogWindow and that WebDialogWindow will have a grid of some sort that is attached to a SQLDataSource that will pull certain information based on the value of the "Row_ID" field from the WebGrid. I'm just not sure how to go about doing this. The Row_ID field does not have to be a hyuperlink...if there is a better way of doing this...but I want the user to know that they can click on the field to see whis other information.
Hi,
You can pass the value from WebGrid as follows: (Please note that here I am assuming that WebDialogWindow is on different aspx page)
Your template control will look like this:igtbl:TemplatedColumn Key="LinkButton"> <CellTemplate> <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click" CommandArgument="<%#Container.Cell.Row.Index%>">LinkButton</asp:LinkButton> </CellTemplate> <Header Caption="LinkButton" Title=""> </Header></igtbl:TemplatedColumn>
Now on your code behind, you use following code inside the click event of the LinkButton control:protected void LinkButton1_Click(object sender, EventArgs e) { LinkButton button = (LinkButton)sender; System.Diagnostics.Debug.WriteLine(String.Format("Button Clicked in row {0}", button.CommandArgument.ToString())); object value = this.UltraWebGrid1.Rows[int.Parse(button.CommandArgument)].Cells.FromKey("LinkButton").Value;
Response.Redirect("Default2.aspx?cell=" + value + ""); }
On your default2.aspx page(which contains the WebDialogWindow) you can use following code to get the value: string cell = Request.QueryString[0]; //now you can use this value as per your logic
I hope this will help you.Let me know if you have any questions with this matter.
NehaDeveloper Support EngineerInfragisticswww.infragistics.com/support
I understand the question differently... It sounds to me like the WebDataGrid and the WebDialogWindow are on the same page, and he wants to open the WebDialogWindow in the same page.
Further, it sounds like he'd like to do it without a postback.
Here is how I did something similar....
TemplateDataField with a literal:
<ig:TemplateDataField Key="btnedit"> <ItemTemplate> <asp:Literal ID="ltrRouteEdit" runat="server"></asp:Literal> </ItemTemplate> <Header Text="" /> </ig:TemplateDataField>
Inject some HTML into the Literal on the InitializeRow event
Protected Sub whdgSummary_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Web.UI.GridControls.RowEventArgs) Handles whdgSummary.InitializeRow
Dim ltr As Literal
ltr = e.Row.Items(whdgSummary.Columns.FromKey("btnedit").Index).FindControl("ltrRouteEdit") Dim RouteId As Long = DataBinder.Eval(e.Row.DataItem, "RouteID") Dim pub As String = DataBinder.Eval(e.Row.DataItem, "pubcode") s = String.Format("<a alt='edit rates' " & _ "href='#' pub='{0}' routeid='{1}' " & _ "onclick='editrates(this); return false;'><img class='imgedit' src='images/edit.gif' " & _ "alt='Edit Rates' align='middle' />Edit Rates</a>", pub, RouteId) ltr.Text = s.ToString End Sub
Stick a javascript function into your page that will respond to the client-side click event, and load the WebDialogWindow
<script type="text/javascript"> function editrates(el) { var dlg = $find("dlgEditRates") dlg.get_contentPane().set_contentUrl("CarrierLedgerDetailEditRates.aspx?pub=" + el.getAttribute("pub") + "&routeid=" + el.getAttribute("routeid"); dlg.set_windowState($IG.DialogWindowState.Maximized); dlg.set_visible(true); } </script>
I placed my detail webgrid in another page and passed in the parameters to it in a querystring, just for simplicity. If you need to detect when the user closes the WebDialogWindow so that you can refresh your parent grid data, wrap the parent WebDataGrid in an update panel, attach a client event to the WebDialogWindow's "WindowStateChanged" event, and use the following javascript.
<script type="text/javascript"> function dlgEditRates_WindowStateChanged(sender, eventArgs) { if ($find("dlgEditRates").get_windowState() == $IG.DialogWindowState.Hidden) { __doPostBack("UpdatePanel1", ''); } } </script>
Instead of passing parameters and accessing by Request.QueryString, is it possible to get parameters by Request.Form in this example?
When you use above, QueryStrings can't have special characters? Otherwise, the above example works perfectly.
Do you have any suggestions/examples?
Thanks