hyperlinkculumn in the grid
-
hi i am creating the hyperlink column like this ........ HyperLinkColumn hlpField = new HyperLinkColumn(); hlpField.DataTextField = "test"; hlpField.HeaderText = "test"; datagrid.Columns.Add(hlpField); and now i want to give the url to this hyperlink field in the itemdatabound event...... how can i do this
-
hi i am creating the hyperlink column like this ........ HyperLinkColumn hlpField = new HyperLinkColumn(); hlpField.DataTextField = "test"; hlpField.HeaderText = "test"; datagrid.Columns.Add(hlpField); and now i want to give the url to this hyperlink field in the itemdatabound event...... how can i do this
Why are you adding it in code instead of in the aspx ? You can subscribe to the itemdatabound event and look for hte column there, but it would be better to build a template that just builds the URL
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
hi i am creating the hyperlink column like this ........ HyperLinkColumn hlpField = new HyperLinkColumn(); hlpField.DataTextField = "test"; hlpField.HeaderText = "test"; datagrid.Columns.Add(hlpField); and now i want to give the url to this hyperlink field in the itemdatabound event...... how can i do this
Hi, instead of using hyperlink column, use linkbutton. find attached the code below. aspx file code: --------------- <asp:DataGrid DataKeyField="event_id" ID="eventsGrid" runat="server" CssClass="textbld" AllowSorting="True" AutoGenerateColumns="False" Width="518px" OnItemDataBound="eventsGrid_ItemDataBound" AlternatingItemStyle-CssClass="alternativeTxt" BorderColor="White" BorderStyle="Solid" BorderWidth="1px" CellPadding="0" HorizontalAlign="Left" > <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <EditItemStyle BackColor="#2461BF" /> <SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <AlternatingItemStyle CssClass="alternativeTxt" /> <ItemStyle HorizontalAlign="Left" CssClass="itemTxt" /> <Columns> <!-- Use the below variable event_id as hidden variables from the database--> <asp:BoundColumn DataField="event_id" Visible="False"></asp:BoundColumn> <!-- bind the hidden variable (event_id) value to the link button using "Eval" function--> <asp:TemplateColumn HeaderText="Ort" HeaderStyle-CssClass="padlist"> <ItemTemplate> <asp:LinkButton ID="lnkCity" runat="server" CommandArgument='<%# Eval("event_id") %>' OnCommand="lnkCity_Command" CssClass="Blacklink"></asp:LinkButton> </ItemTemplate> <ItemStyle CssClass="eventsTxt" /> </asp:TemplateColumn> </Columns> <HeaderStyle CssClass="head_txt Head_R1" /> </asp:DataGrid> .cs file code: --------------- In the onclick event of the linkbutton in the datagrid, give the link url as below. protected void lnkCity_Command(object sender, CommandEventArgs e) { Response.Redirect("Popup.aspx"); }
Kodee