Gridview not displaying data - asp.net

this is my gridview page.
style="top: 315px; left: 47px; position: absolute; height: 121px; width: 979px"
AllowPaging="True" BackColor="White" BorderColor="#CC9966" BorderStyle="None"
BorderWidth="1px">
<Columns>
<asp:BoundField DataField="DepartureTime" HeaderText="DepartureTime"
SortExpression="DepartureTime" />
<asp:BoundField DataField="Comments" HeaderText="Comments"
SortExpression="Comments" />
<asp:BoundField DataField="Time" HeaderText="Time"
SortExpression="Time" />
<asp:BoundField DataField="Data" HeaderText="Data"
SortExpression="Data" />
<asp:BoundField DataField="Locations" HeaderText="Location"
SortExpression="Location" />
<asp:BoundField DataField="Destination" HeaderText="Destination"
SortExpression="Destination" />
<asp:BoundField DataField="TrackingID" HeaderText="TrackingID"
SortExpression="TrackingID" />
<asp:BoundField DataField="Shipper" HeaderText="Shipper"
SortExpression="Shipper" />
<asp:BoundField DataField="Address" HeaderText="Address"
SortExpression="Address" />
<asp:BoundField DataField="Receiver" HeaderText="Receiver" SortExpression="Receiver" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
<asp:BoundField DataField="Origin" HeaderText="Origin"
SortExpression="Origin" />
<asp:BoundField DataField="ReceiverAddres" HeaderText="ReceiverAddres"
SortExpression="ReceiverAddres" />
</Columns>
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="#330099" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<SortedAscendingCellStyle BackColor="#FEFCEB" />
<SortedAscendingHeaderStyle BackColor="#AF0101" />
<SortedDescendingCellStyle BackColor="#F6F0C0" />
<SortedDescendingHeaderStyle BackColor="#7E0000" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:sqlConStr %>"
SelectCommand="SELECT * FROM [trackingInfo] WHERE ([TrackingID] = #TrackingID)">
<SelectParameters>
<asp:FormParameter FormField="trackingnumber" Name="TrackingID" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
this is my form page.
this work well when i created is using visual studio and sql management studio
but when i hosted it to my windows web hosting and use the database in my control panel which webadmin is admin software there. this gridview stops working and its showing this error message "Not Found
The requested document was not found on this server.
Web Server at mydomin.org.uk "
i have checked my connectionstring at the web.config file that is good there is no problem there.
please help me for i have put in all ideal to this but is not working.
thanks in advance.

kindly manage your connection string in web.config file......
<ConnectionStrings>
<!--Live--><add name="ConnectionString" connectionString="server=64.5.122.60;user id=user123;password=password;database=databaseName;port=9293" providerName="MySql.Data.MySqlClient"/>
<!--Local--><add name="ConnectionString" connectionString="server=localhost;user id=root;password=root;database=databaseName;port=3306" providerName="MySql.Data.MySqlClient"/>
</ConnectionStrings>
Hope it helpss

protected void Page_Load(object sender, EventArgs e)
{
BindGrid();
}
private void BindGrid()
{
MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["sqlConStr"].ConnectionString);
string sql = "Select * from tableName;";
MySqlCommand command = new MySqlCommand(sql,connection);
command.CommandType = CommandType.Text;
MySqlDataAdapter adapter = new MySqlDataAdapter(command);
DataTable datatable = new DataTable();
adapter.Fill(datatable);
GridView1.DataSource=datatable;
GridView1.DataBind();
}
This will bind your grid manuly... hope this will help you again... thanks

Related

Dinamically created checkboxes, event handler and more - vb.NET asp.NET

I'm trying to manage the checkall control in a gridview but I'm facing several problems.
This is my gridview control:
<asp:GridView ID="gvShow" runat="server" AutoPostback="True" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" Height="224px" HorizontalAlign="Center" Width="761px" CellPadding="4" ForeColor="#333333" DataSourceID="sid_db">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField ItemStyle-Width="50px">
<HeaderTemplate>
<asp:CheckBox ID="chkCheckAll" runat="server" AutoPostBack="False" OnCheckedChanged="chkCheckAll_CheckedChanged" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkCheck" runat="server" />
</ItemTemplate>
<ItemStyle Width="50px"></ItemStyle>
</asp:TemplateField>
<asp:BoundField DataField="Scope" HeaderText="Scope" SortExpression="Scope" />
<asp:BoundField DataField="Brand" HeaderText="Brand" SortExpression="Brand" />
<asp:BoundField DataField="Site ID" HeaderText="Site ID" SortExpression="Site ID" />
<asp:BoundField DataField="Site Name" HeaderText="Site Name" SortExpression="Site Name" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:BoundField DataField="CAP" HeaderText="CAP" SortExpression="CAP" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />
<asp:BoundField DataField="Master_ID" HeaderText="Master_ID" SortExpression="Master_ID" ItemStyle-CssClass="hiddencol" HeaderStyle-CssClass="hiddencol">
<HeaderStyle CssClass="hiddencol"></HeaderStyle>
<ItemStyle CssClass="hiddencol"></ItemStyle>
</asp:BoundField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
First problem:
The checkbox controls are dynamically created and I honestly have the feeling that I should create an event handler for those, but I don't know how to do it nor I know where to put/write that code. I just see those controls are not recognized once I try to reference them in my code.
Second problem:
Since I'm pretty much a newbie, I made a step back and tested with some junk code if I was able to have all the checkboxes dinamically checked at page load... here is my test... the result a complete failure, nothing happens. I even tried to put the code in the init event, but the result is the same.
For Each row As GridViewRow In gvShow.Rows
DirectCast(row.FindControl("chkCheck"), CheckBox).Checked = True
Next
I would be grateful if anyone could help me with these problems.
Thanks in advance for your time.
Regards,
I have found the answer myself. I had to change the code as follow:
<asp:GridView ID="gvShow" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" Height="224px" HorizontalAlign="Center" Width="761px" CellPadding="4" ForeColor="#333333">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField ItemStyle-Width="50px">
<HeaderTemplate>
<asp:CheckBox ID="ChkSelectAll" runat="server" Autopostback="True" OnCheckedChanged="ChkSelectAll_CheckedChanged" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="ChkSigleItem" runat="server" OnCheckedChanged="ChkSigleItem_CheckedChanged" />
</ItemTemplate>
<ItemStyle Width="50px"></ItemStyle>
</asp:TemplateField>
<asp:BoundField DataField="Scope" HeaderText="Scope" SortExpression="Scope" />
<asp:BoundField DataField="Brand" HeaderText="Brand" SortExpression="Brand" />
<asp:BoundField DataField="Site ID" HeaderText="Site ID" SortExpression="Site ID" />
<asp:BoundField DataField="Site Name" HeaderText="Site Name" SortExpression="Site Name" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:BoundField DataField="CAP" HeaderText="CAP" SortExpression="CAP" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />
<asp:BoundField DataField="Master_ID" HeaderText="Master_ID" SortExpression="Master_ID" ItemStyle-CssClass="hiddencol" HeaderStyle-CssClass="hiddencol">
<HeaderStyle CssClass="hiddencol"></HeaderStyle>
<ItemStyle CssClass="hiddencol"></ItemStyle>
</asp:BoundField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
And then:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack = False Then
''Set value for default SQL query
Dim query As String
query = "SELECT Sites.Master_ID AS Master_ID, Scopes.Name AS Scope, Brands.Extension AS [Brand], Sites.ID AS [Site ID], Sites.Name AS [Site Name], Sites.Address, Sites.CAP, Sites.City, Countries.Name AS Country FROM Sites INNER JOIN Scopes ON Sites.scope_ID = Scopes.ID INNER JOIN Brands ON Sites.brand_ID = Brands.ID INNER JOIN Countries ON Sites.country_ID = Countries.ID"
sid_db.SelectCommand = query
gvShow.DataSource = sid_db
gvShow.DataBind()
End If
End Sub
Protected Sub ChkSelectAll_CheckedChanged(sender As Object, e As EventArgs)
Dim a As Boolean = DirectCast(sender, CheckBox).Checked
For Each row As GridViewRow In gvShow.Rows
Dim cbx As CheckBox = row.FindControl("ChkSigleItem")
cbx.Checked = a
Next
End Sub

Formatting datetime object

I have a dateTime field that i am showing in GridView. The problem is I just need to Show The date of the system And not the time but it shows both date and time. What appropriate formatting should be applied?
this sets the date in textbox:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TextBoxdate.Text = DateTime.Today.ToShortDateString();
}
}
Retrieves from table:
public static List<Workassign> GetTable()
{
List<Workassign> listValues = new List<Workassign>();
string connectionString = "server=(local);database=project_zeshan;Integrated Security=SSPI";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("Select * from Assign_Work", con);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Workassign ob = new Workassign();
ob.listItem_1 =rdr["listitem_1"].ToString() ;
ob.listItem_2 = rdr["listitem_2"].ToString();
ob.Description = rdr["Description"].ToString();
ob.Date= DateTime.Parse(rdr["Date"].ToString());
ob.Image = rdr["Image"].ToString();
listValues.Add(ob);
}
return listValues;
}
And the gridView.aspx code:
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333" GridLines="None"
onselectedindexchanged="GridView1_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="listitem_1" HeaderText="ListItem1" />
<asp:BoundField DataField="listItem_2" HeaderText="listItem2" />
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:BoundField DataField="Date" HeaderText="Date" />
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height= "50px" Width = "100px" ImageUrl='<%# Bind("Image") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
</div>
</form>
Try this:
<asp:BoundField DataField="Date" HeaderText="Date" DataFormatString="{0:MM/dd/yyyy}" />
You can format the DateTime however you like using ToString() with format string created from the choices here: MSDN - Custom Date and Time Format Strings
// For a standard U.S.-style date:
myDateTime.ToString("MM/dd/yyyy")
// For ISO-style:
myDateTime.ToString("yyyy-MM-dd")
And so on.
EDIT
#JohnH correctly pointed out that in the specific context of working with a GridView, you wouldn't use ToString or other methods, but rather provide a DataFormatString attribute. I'll leave my answer for general use cases of formatting a date and the link to the MSDN resource containing the available format strings.

Incorrect syntax near 'int' when using updatecommand on a gridview

I have a problem that when ever I try to update a record in the database using gridview update event handler and an updatecommand in sqldatascource
I get the following exception
Incorrect syntax near 'int'.
the weird thing is when I reload the page I find that the record was updated successfully but yet I need this exception message not to appear what should I do
update event handler
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = GridView1.Rows[e.RowIndex];
int BusId = Convert.ToInt32(((DataKey)GridView1.DataKeys[e.RowIndex]).Value);
TextBox Capacity =(TextBox) row.Cells[1].Controls[0];
TextBox DriverName =(TextBox) row.Cells[3].Controls[0];
TextBox Phone =(TextBox) row.Cells[4].Controls[0];
SqlDataSource1.UpdateParameters.Add("capaity", Capacity.Text);
SqlDataSource1.UpdateParameters.Add("id", BusId.ToString());
SqlDataSource1.UpdateParameters.Add("driver", DriverName.Text);
SqlDataSource1.UpdateParameters.Add("phone", Phone.Text);
SqlDataSource1.Update();
}
gridview asp.net code
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="Bus Number" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" Height="326px" Width="1017px" OnRowUpdating="GridView1_RowUpdating">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="Bus Number" HeaderText="Bus Number" ReadOnly="True" SortExpression="Bus Number" />
<asp:BoundField DataField="Capacity" HeaderText="Capacity" SortExpression="Capacity" />
<asp:BoundField DataField="NumberOfBooking" HeaderText="NumberOfBooking" SortExpression="NumberOfBooking" ReadOnly="True" />
<asp:BoundField DataField="Driver" HeaderText="Driver" SortExpression="Driver" />
<asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" ShowHeader="False" />
<asp:BoundField DataField="Date Added" HeaderText="Date Added" SortExpression="Date Added" DataFormatString="{0:MM/dd/yyyy}" ReadOnly="True" />
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
the updatecommand
UpdateCommand="UPDATE Buses SET Capacity = #capaity WHERE VechileId = #id ;UPDATE Vechile SET Driver = #driver, Phone = #phone
WHERE VechileId = #id">

show data in gridview after selection from dropdown list

Hi i just want to show data in my gridview after selecting value from dropdown list and after selecting my dropdown list when i press on search button data can be seen in gridview. My gridview is connected with my database how can i do that my code is this:
aspx page:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333"
GridLines="None">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Portal" HeaderText="Portal"
SortExpression="Portal" />
<asp:BoundField DataField="TID" HeaderText="TID" SortExpression="TID" />
<asp:BoundField DataField="PNR" HeaderText="PNR" SortExpression="PNR" />
<asp:BoundField DataField="TicketNumber" HeaderText="TicketNumber"
SortExpression="TicketNumber" />
<asp:BoundField DataField="ESACCode" HeaderText="ESACCode"
SortExpression="ESACCode" />
<asp:BoundField DataField="WaiverCode" HeaderText="WaiverCode"
SortExpression="WaiverCode" />
<asp:BoundField DataField="Remarks" HeaderText="Remarks"
SortExpression="Remarks" />
<asp:BoundField DataField="UnusedTicketAmount" HeaderText="UnusedTicketAmount"
SortExpression="UnusedTicketAmount" />
<asp:BoundField DataField="ddlUnusedAmount" HeaderText="ddlUnusedAmount"
SortExpression="ddlUnusedAmount" />
<asp:BoundField DataField="AirlinePenality" HeaderText="AirlinePenality"
SortExpression="AirlinePenality" />
<asp:BoundField DataField="ddlAirlinePenality" HeaderText="ddlAirlinePenality"
SortExpression="ddlAirlinePenality" />
<asp:BoundField DataField="NetRefundProcess" HeaderText="NetRefundProcess"
SortExpression="NetRefundProcess" />
<asp:BoundField DataField="ddlNetRefundProcess"
HeaderText="ddlNetRefundProcess" SortExpression="ddlNetRefundProcess" />
<asp:BoundField DataField="RefundableCommission"
HeaderText="RefundableCommission" SortExpression="RefundableCommission" />
<asp:BoundField DataField="ddlRefundableCommission"
HeaderText="ddlRefundableCommission" SortExpression="ddlRefundableCommission" />
<asp:BoundField DataField="CouponRefunded" HeaderText="CouponRefunded"
SortExpression="CouponRefunded" />
<asp:BoundField DataField="RefundType" HeaderText="RefundType"
SortExpression="RefundType" />
<asp:BoundField DataField="DateTime" HeaderText="DateTime"
SortExpression="DateTime" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:BartConnectionString %>"
SelectCommand="SELECT * FROM [Test]"></asp:SqlDataSource>
code on aspx.cs page
public void GridViewBind()
{
SqlCommand cmd = new SqlCommand("select * from Test where ID=" + DropDownList1.SelectedValue + "", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Test");
GridView1.DataSource = ds.Tables["Test"];
GridView1.DataBind();
}
protected void btnSearch_Click(object sender, EventArgs e)
{
this.GridViewBind();
}
After selecting value from my dropdown list Error : Invalid column name 'TRAVELONG'
Is ID a string? If so, you need inner quotes for the ID field:
SqlCommand cmd = new SqlCommand("select * from Test where ID='" + DropDownList1.SelectedValue + "'", con);
Otherwise, it may be considering the selected value as a column...

How to make a Gridview template field select the row of data?

I have a command field in a gridview, that as it is, works as it should. When i select it, the row is hilighted. However, i needed to convert this field into a template, so i could give it a ID that i could reference when using a AJAX Mobal control. I did this, and i am able to reference it with my Ajax control just fine, but, now this field does not select the row in the Gridview? The Select value is needed for the Ajax control to pull the data thru. So i think my issue is, How do i use this command field as a template, AND have it select the row? I hope i am explaining my issue correctly.
Here is the snippet of code when i convert it into a template.
Thank you!
<asp:GridView ID="GridView3" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="3" DataKeyNames="Contact_ID" DataSourceID="SqlDataSource2" ForeColor="#333333" GridLines="None" PageSize="6">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Select" Text="Edit"></asp:LinkButton>
<asp:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="LinkButton1" PopupControlID="DetailsView1" BackgroundCssClass="modalBackground"></asp:ModalPopupExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Contact_ID" HeaderText="Contact_ID" InsertVisible="False" ReadOnly="True" SortExpression="Contact_ID" Visible="False" />
<asp:BoundField DataField="Contact_Assigned_Username" HeaderText="Username" SortExpression="Contact_Assigned_Username" />
<asp:BoundField DataField="Contact_First_Name" HeaderText="First Name" SortExpression="Contact_First_Name" />
<asp:BoundField DataField="Contact_Last_Name" HeaderText="Last Name" SortExpression="Contact_Last_Name" />
<asp:BoundField DataField="Contact_Email_Address" HeaderText="Email Address" SortExpression="Contact_Email_Address" />
<asp:BoundField DataField="Contact_Cell_Phone" HeaderText="Cell Phone" SortExpression="Contact_Cell_Phone" />
<asp:CheckBoxField DataField="Contact_Administrator" HeaderText="Admin" SortExpression="Contact_Administrator" />
<asp:CheckBoxField DataField="Contact_LineStat_Triggers_Email" HeaderText="Email Triggers" SortExpression="Contact_LineStat_Triggers_Email" />
<asp:CheckBoxField DataField="Contact_LineStat_Triggers_Text" HeaderText="Text Triggers" SortExpression="Contact_LineStat_Triggers_Text" />
<asp:CheckBoxField DataField="Contact_Web_Portal" HeaderText="Web Access" SortExpression="Contact_Web_Portal" />
<asp:BoundField DataField="Contact_Customer_ID" HeaderText="Contact_Customer_ID" SortExpression="Contact_Customer_ID" Visible="False" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
In the RowDataBound event, try something like this:
protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e)
{
LinkButton btn = (LinkButton)e.Row.FindControl("LinkButton1");
btn.OnClientClick = Page.ClientScript.GetPostBackEventReference(GridView3, "Select$" + e.Row.RowIndex.ToString()));
}

Resources