Showing posts with label dataset. Show all posts
Showing posts with label dataset. Show all posts

Saturday, March 31, 2012

Text box text from dataset

i have dataset with the result and i bind it to datagrid

in datagrid i use to display text for hyperlink

<asp:datagrid

'<%# DataBinder.Eval(Container.DataItem, "ForumName") %>'

</asp:datagrid>

now if i have hyperlink some where on page and i need the text of this hyperlink to show the forumname what user has selected.how to do that.the dataset has the result and i want the ForumName from the dataset to hyperlink which is on the page not in datagrid.

Hello,

The code below creates a GridView control that have a hyperlink column which

sends the ID to other page:

Here is the simple code which you can use:

<asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="White"
BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1"

GridLines="None" AutoGenerateColumns="False">
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
<Columns>
<asp:BoundField DataField="CategoryID" />
<asp:HyperLinkField DataNavigateUrlFields="CategoryID"

DataNavigateUrlFormatString="SmallWindow.aspx?id={0}"
DataTextField="CategoryName" NavigateUrl="SmallWindow.aspx" />
<asp:BoundField DataField="Description" />
</Columns>
</asp:GridView>


So, now when you click the CategoryName you will be redirected to SmallWindow.aspx page.

Wednesday, March 28, 2012

Text Control value doesnt update

I have created an aspx page which onload populates a dataset then binds various controls to the relevant columns. Then on editing one of the text boxes on the click of a button I want to update the database. I have tried various updates but to no avail. I have narrowed the problem down to that on stepping through the code the value held in memory doesnt recognise that the text held in the control has changed from the original text. Any Ideas.If you are initialising your text box values in the Page_Load event, you must enclose your code in the following IF block:
If Not IsPostBack Then
'
' Initialisation code goes here...
'
End If
Worked a treat cheers, how simple but id never have guessed.