How to get the value of a cell from Grid View.

Posted by Gokul under ASP.NET on 1/3/2012 | Points: 10 | Views : 2744 | Status : [Member] | Replies : 3
Dear Friends,
I am developing a online travels project. I one of the page, i placed the grid to show the tickets available on that particular date.The grid contains From, To, Date, Route , checkavail(linkbutton). I have placed a link button inside the grid . If the user clicks the link button, the value in the column route has to be selected and stored in a variable for later usage. can any one help me on this.



Thanks,
Gokul.

Thanks and Regards,
GokulNath Nithy.



Responses

Posted by: Prabhakar on: 1/3/2012 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Gokul . .


U do this with QueryString . . . in ur HyperLinkField . . u add QueryString .then Next page u Ritrive all values and show on Control . .for use . .

 <asp:HyperLink id="link1"  runat="server" Text='Print' NavigateUrl='<%#"FormPrintss.aspx?ssno=" + Eval("ssno") %>'></asp:HyperLink>


Best Regard's
Prabhakar

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 1/3/2012 [Member] Silver | Points: 25

Up
0
Down


Convert that column to TemplateField
You can pass the column value as commndargument along with the linkbutton
and trap the value in its click event

Thanks,
Sanjay

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 1/3/2012 [Member] Silver | Points: 25

Up
0
Down
Hi, Gokul,
Try This.....
<asp:TemplateField HeaderText="Posted Questions" >
<ItemTemplate>
<asp:LinkButton ID="lblTopicHeading" CssClass="linkBtn" runat="server" Text="Click Here"
OnClick="lnk_getRoute_Click" CommandArgument='<%# Bind("RouteValue")%>' />
</ItemTemplate>
</asp:TemplateField>
///////////////////////////////////////////////

protected void lnk_getRoute_Click(object sender, EventArgs e)
{
LinkButton lnbGetRouteValue = (LinkButton)sender;
int valRoute=int.Parse(lnbGetRouteValue.CommandArgument.ToString())
if (codition)
{
//do your task
}


}

Thanks,
Sanjay

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response