How to multiply textbox value using javascript? - c#

<asp:GridView ID="GVFeedType" runat="server" Style="margin-bottom: 6px" BorderColor="#BDBDBD"
CssClass="center" Width="500px" AutoGenerateColumns="false">
<EmptyDataTemplate>
No Records found</EmptyDataTemplate>
<Columns>
<asp:BoundField HeaderText="SNo" DataField="SNo" ItemStyle-Width="50px" />
<asp:BoundField HeaderText="Feed Type" DataField="FeedType" ItemStyle-Width="200px" />
<asp:TemplateField HeaderText="Rate/Kg" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:TextBox ID="txtrate" runat="server" Width="100px" OnTextChanged="txtrate_TextChanged"
AutoPostBack="true" />
<asp:RequiredFieldValidator ID="RFVrecdate1" runat="server" ControlToValidate="txtrate"
Display="None" ErrorMessage="Must Enter Rate" ValidationGroup="duereport"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Rate/50 Kg" ItemStyle-Width="80px">
<ItemTemplate>
<asp:Label ID="lbl50kg" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I tried this code..
protected void txtrate_TextChanged(object sender, EventArgs e)
{
GridViewRow currentRow = (GridViewRow)(sender as TextBox).Parent.Parent;
float rate = 0;
float kgrate50 = 50;
rate = Convert.ToSingle((sender as TextBox).Text.Trim());
kgrate50 = rate * kgrate50;
(currentRow.Cells[3].FindControl("lbl50kg") as Label).Text = kgrate50.ToString();
GVFeedType.Rows[currentRow.RowIndex + 1].Cells[2].FindControl("txtrate").Focus();
}
This code is fine ,Tab not working...
i have a textbox in a grid view control,when i enter some value like 2,3,4 ..then it multiply with 50 ...and it shows output in lable control..here label also in a gridview..how can i solve it..please help me..

I would add CSs class to text box
<asp:TextBox ID="txtrate" runat="server" CssClass="TextBoxToHandle" Width="100px" OnTextChanged="txtrate_TextChanged"
AutoPostBack="true" />
Since using tab throw focusout event you need to subscribe to it
$(function(){
$(".TextBoxToHandle").focusout(function(){
//Do your code here this would be element which you focus left
});
})

Related

How to add RequiredExpressionValidator to the "Cantitate" field

I have a shopping cart that can be updated by the user. I want to add a validation method to the "Cantitate" field, so that the user can only add positive integers.
html
<asp:GridView ID="CartList" runat="server" AutoGenerateColumns="False" ShowFooter="True" GridLines="Vertical" CellPadding="4"
ItemType="Magazin.Models.CartItem" SelectMethod="GetShoppingCartItems"
CssClass="table table-striped table-bordered">
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="Nr. articol" SortExpression="ProductID" />
<asp:BoundField DataField="Product.ProductName" HeaderText="Denumire" />
<asp:BoundField DataField="Product.UnitPrice" HeaderText="Preț (per bucată)" DataFormatString="{0:c}" />
<asp:TemplateField HeaderText="Cantitate">
<ItemTemplate>
<asp:TextBox ID="PurchaseQuantity" Width="40" runat="server" Text="<%#: Item.Quantity %>"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total de plată pentru acest produs">
<ItemTemplate>
<%#: String.Format("{0:c}", ((Convert.ToDouble(Item.Quantity)) * Convert.ToDouble(Item.Product.UnitPrice)))%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Șterge">
<ItemTemplate>
<asp:CheckBox ID="Remove" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Here is the UpdateCartItems:
public List<CartItem> UpdateCartItems()
{
using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
{
String cartId = usersShoppingCart.GetCartId();
ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count];
for (int i = 0; i < CartList.Rows.Count; i++)
{
IOrderedDictionary rowValues = new OrderedDictionary();
rowValues = GetValues(CartList.Rows[i]);
cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]);
CheckBox cbRemove = new CheckBox();
cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove");
cartUpdates[i].RemoveItem = cbRemove.Checked;
TextBox quantityTextBox = new TextBox();
quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity");
cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString());
}
usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates);
CartList.DataBind();
lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal());
return usersShoppingCart.GetCartItems();
}
}
The update button of the shopping cart, that updates the cart by calling the UpdateCartItems
protected void UpdateBtn_Click(object sender, EventArgs e)
{
UpdateCartItems();
}
<asp:GridView ID="CartList" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Message" HeaderText="Nr. articol" SortExpression="ProductID" />
<asp:TemplateField HeaderText="Cantitate">
<ItemTemplate>
<asp:TextBox ID="YourTextBox" runat="server" />
<asp:CompareValidator runat="server"
ControlToValidate="YourTextBox"
Operator="DataTypeCheck"
Type="Integer"
ErrorMessage="Enter a valid integer"
Display="Dynamic" />
<asp:CompareValidator runat="server"
ControlToValidate="YourTextBox"
Operator="GreaterThanEqual"
ValueToCompare="0"
Type="Integer"
ErrorMessage="The integer cannot be less than zero"
Display="Dynamic" />
<%--<asp:TextBox ID="PurchaseQuantity" Width="40" runat="server" Text="" TextMode="Number" min="0"></asp:TextBox>
<asp:RegularExpressionValidator runat="server" Display="Dynamic" ControlToValidate="PurchaseQuantity" ErrorMessage="Enter a valid value" ForeColor="Red" ValidationExpression="\s+\d{1,6}\s+"></asp:RegularExpressionValidator>--%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

How to clear a particular row from a Gridview on display after clicking on Delete Button?

Below is my aspx code associated with Gridview:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" HorizontalAlign="Center" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowDataBound="GridView1_RowDataBound" OnRowUpdating="GridView1_RowUpdating" OnRowDeleting="GridView1_RowDeleting" HeaderStyle-BackColor="#00a400" HeaderStyle-ForeColor="White">
<Columns>
<asp:BoundField DataField="Product_No" HeaderText="Product No" />
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height="100px" Width="120px"
ImageUrl='<%#"data:Image/png/jpg/jpeg/gif/bmp;base64," + Convert.ToBase64String((byte[])Eval("Product_Image")) %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Product_Name" HeaderText="Product" />
<asp:BoundField DataField="Barcode_No" HeaderText="Barcode" />
<asp:BoundField DataField="Product_Category_Name" HeaderText="Category" />
<asp:TemplateField HeaderText="Price" >
<ItemTemplate>
<asp:TextBox ID ="TextBox3" runat="server" Width="80px" DataField="Product_Price" Text='<%#string.Format("{0:0.00}",Eval("Product_Price"))%>'/>
<asp:Label ID="Label4" Text="AUD" runat="server"></asp:Label>
<asp:Button ID ="Button10" runat="server" OnClick="Price_Update_Click" ValidationGroup="UpdatePrice" CommandArgument="Button11" CommandName="Update" Text="Update" />
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="TextBox3" ErrorMessage="Must be greater than 0.09 .. Cannot accept integer or character or more than 2 numbers after decimal" Operator="GreaterThan" Type="Currency" ValueToCompare="0.09" Display="Dynamic" />
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Numbers with only 2 digits after decimal" ControlToValidate="TextBox3" ValidationExpression="^\d{1,9}\.\d{1,2}$"></asp:RegularExpressionValidator>--%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity" >
<ItemTemplate>
<asp:TextBox ID ="TextBox4" runat="server" Width="60px" DataField="Product_Quantity" Text='<%#Eval("Product_Quantity")%>' />
<asp:Button ID ="Button11" runat="server" OnClick="Quantity_Update_Click" ValidationGroup="UpdateQuantity" CommandArgument="Button12" CommandName="Update" Text="Update" />
<%--<asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="TextBox4" ErrorMessage="Must be greater than 0 .. Cannot accept decimal or character" Operator="GreaterThan" Type="Integer" ValueToCompare="0" Display="Dynamic" />--%>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Cannot accept decimal or character" ControlToValidate="TextBox4" ValidationExpression="^[0-9]*$" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:Label ID="Label5" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Grocery_Branch_Name" HeaderText="Branch" />
<asp:TemplateField HeaderText="Remove Product">
<ItemTemplate>
<asp:Button ID="Button12" runat="server" OnClick="Delete_Click" ValidationGroup="DeleteProduct" CommandArgument="Button6" CommandName="Delete" Text="Delete" CausesValidation ="false" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Then below is cs code associated with deleting a product through stored procedure:
protected void Delete_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
GridViewRow row = (GridViewRow)btn.NamingContainer;
string ProductId = row.Cells[0].Text;
string CS;
CS = ConfigurationManager.ConnectionStrings["Grocery_DemoConnectionString"].ConnectionString; ;
SqlConnection con = new SqlConnection(CS);
SqlCommand cmd = new SqlCommand("DeleteProduct", con);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("#ProductNo", ProductId);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox("Product has been removed from the stock");
}
protected void GridView1_RowDeleting(object sender, EventArgs e)
{
}
The Delete Stored Procedure is working successfully and a particular product in is being deleted from the database table on Delete Click Event. The message box also gets displayed "Product has been removed from the stock"
However, the issue is that the Gridview still displays that particular product row even though that particular product has been already deleted from the database.
If I manually click on Refresh button, then that particular deleted product row is not displayed in the Gridview anymore.
But what I want to achieve is that after clicking on Delete button, that particular product row shouldn't be displayed in the Gridview anymore so that I don't have to manually solve it through clicking on Refresh button.
If there is something I need to include in my cs code OR aspx code then
kindly do mention it so that I can try and test it out.

Databinding issue with Eval/Bind - C# Webforms asp.net

I'm working on an existing project, doing some updates and have troubles setting the value of "FenSelectedValue" in the "FenDropDownListRoles" Control.
I keep getting the error:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control in repeater control
But the eval in the Label control works fine. I've been reading here and there, and I read things about it not being bound at the right time so I moved the control from "EditItemTemplate" where it eventually should be to "ItemTemplate", to test it, but still no luck..
<ItemTemplate>
<asp:Label ID="lblRolOmschrijving" Text='<%# Eval("Rol_omschrijving") %>' runat="server" />
<fen:FenDropDownListRoles ID="ddlRoles" FenSelectedValue='<%# Eval("Rol_omschrijving") %>' runat="server" Watermark="AdministratorType" Required="true" ValidationGroup="grpAddUser" />
</ItemTemplate>
Here's how I've learned to set drop down selected items in a grid view.
Example grid:
<div id="gridContainerFormulations">
<script type="text/javascript">
$(document).ready(function () {
//This is done here, instead of codebehind, because the SelectedValue property of the drop down list
//simply does not work when databinding. I set the two 'hid' values via the RowEditing event
$("[id$='drpLotNumber']").val($("#hidSelectedFormulationLotNo").val());
});
</script>
<asp:hiddenfield runat="server" id="hidSelectedFormulationLotNo" value="-1" />
<asp:gridview id="dgrStudyFormulations" cssclass="data" runat="server" allowpaging="False" autogeneratecolumns="False"
datakeynames="Id, FormulationLotNo, FormulationNo">
<Columns>
<asp:BoundField HeaderText="Formulation" ReadOnly="True" DataField="FormulationName" />
<asp:TemplateField HeaderText="Lot #">
<EditItemTemplate>
<asp:dropdownlist ID="drpLotNumber" AddBlank="False" runat="server" />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblLotNumber" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "FormulationLot.Name")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="AI in Formulation" ReadOnly="True" DataField="ActiveIngredientName" />
<asp:TemplateField HeaderText="AI Of Interest">
<EditItemTemplate>
<asp:CheckBox ID="chkOfInterest" Checked='<%# DataBinder.Eval(Container.DataItem, "OfInterest")%>' runat="server" />
</EditItemTemplate>
<ItemTemplate>
<%--<asp:Label ID="lblOfInterest" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "OfInterest")%>' />--%>
<asp:image runat="server" id="imgOfInterest" Visible="False" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="AI Amount" ReadOnly="True" DataField="AIAmountText" />
<asp:CommandField ShowEditButton="True" ShowCancelButton="True" ShowDeleteButton="True"/>
</Columns>
</asp:gridview>
Then in row_editing event of grid:
SelectedFormulationLotNo = CType(dgrStudyFormulations.DataKeys(e.NewEditIndex)("FormulationLotNo"), String)
Which sets the hidden field in the HTML
Property SelectedFormulationLotNo() As String
Get
Return hidSelectedFormulationLotNo.Value.Trim()
End Get
Set(value As String)
If String.IsNullOrEmpty(value) Then
hidSelectedFormulationLotNo.Value = String.Empty
Else
hidSelectedFormulationLotNo.Value = value.Trim()
End If
End Set
End Property
And then the jQuery function call sets the correct option in the newly editable row in the grid.
How I finally did it(but leaving the answer on Rake36's answer, since it probably works too and got me in the direction I needed) Since I couldn't get the Javascript to work for some reason and I knew from messing around that I could get the value of labels in "RowDataBound" I combined the method of Rake36 with the hidden field and set the value in the codebehind (in RowDataBound)
In the codebehind:
protected void gvwUsers_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList DropDownListRol = (DropDownList)e.Row.FindControl("ddlRolOmschrijving");
if (e.Row.RowType == DataControlRowType.DataRow && DropDownListRol != null)
{
DsFenVlaanderen.tb_rolDataTable dtRole = DsFenVlaanderen.RolTableAdapter.GetData();
//Fill Dropdownlist
DropDownListRol.DataSource = dtRole;
DropDownListRol.DataValueField = dtRole.Rol_IDColumn.ColumnName;
DropDownListRol.DataTextField = dtRole.Rol_omschrijvingColumn.ColumnName;
DropDownListRol.DataBind();
//Set Selected value
DropDownListRol.Items.FindByValue(hidSelectedRole.Value).Selected = true;
}
}
protected void gvwUsers_RowEditing(object sender, GridViewEditEventArgs e)
{
//Set hiddenfield to value of Rol_ID
hidSelectedRole.Value = gvwUsers.DataKeys[e.NewEditIndex].Values["Rol_ID"].ToString();
}
This is my grid:
<asp:hiddenfield runat="server" id="hidSelectedRole" value="-1" />
<fen:FenGridViewSelectable ID="gvwUsers" runat="server" Selectable="False"
DataSourceID="dsUsers" EnableModelValidation="True" SkinID="Blue"
AllowSorting="True" OnDataBound="gvwUsers_DataBound" OnRowDeleting="gvwUsers_RowDeleting"
AutoGenerateColumns="False" DataKeyNames="User_ID,Rol_ID" OnRowDataBound="gvwUsers_RowDataBound" OnRowEditing="gvwUsers_RowEditing" OnRowUpdating="gvwUsers_RowUpdating">
<Columns>
<asp:BoundField DataField="User_ID" HeaderText="Gebruikersnaam" ReadOnly="True" SortExpression="User_ID" />
<asp:BoundField DataField="User_ID_EXT" HeaderText="Naam" ReadOnly="true" SortExpression="User_ID_EXT" />
<%-- <asp:BoundField DataField="Rol_omschrijving" HeaderText="Type bestuurder" SortExpression="Rol_omschrijving" /> --%>
<asp:TemplateField HeaderText="Type bestuurder" SortExpression="Rol_omschrijving">
<ItemTemplate>
<asp:Label ID="lblRolOmschrijving" Text='<%# Eval("Rol_omschrijving") %>' runat="server"/>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlRolOmschrijving" runat="server" DataField="Rol_omschrijving"></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<fen:FenTemplateField HeaderStyle-Width="100px">
<ItemTemplate>
<fen:FenButton ID="btnEdit" runat="server" Function="Edit" />
<fen:FenButton ID="btnDelete" runat="server" Function="Delete" />
</ItemTemplate>
<EditItemTemplate>
<fen:FenButton ID="btnUpdate" runat="server" Function="Update" />
<fen:FenButton ID="btnCancel" runat="server" Function="CancelInline" />
</EditItemTemplate>
</fen:FenTemplateField>
</Columns>
</fen:FenGridViewSelectable>
<asp:ObjectDataSource ID="dsUsers" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="FenVlaanderen.DsFenVlaanderenTableAdapters.vUsersTableAdapter"></asp:ObjectDataSource>
<asp:Label ID="lblNoResults" runat="server" Visible="false" CssClass="error">Er werden geen gebruikers gevonden.</asp:Label>
<asp:Label ID="lblDeleteNotAllowed" runat="server" Visible="false" CssClass="error" />
<fen:AddUser ID="addUser" runat="server" OnFenControlSaved="addUser_FenControlSaved" />
</ContentTemplate>

Gridview BoundField Editing Textbox Enable Multiline

I don't know if its possible to display a fixed textbox with multiline, when clicking edit link in gridview.
Codes:
<asp:BoundField DataField="AboutUs_Text" HeaderText="About Us Editor" ItemStyle-CssClass="editing" >
<ControlStyle Width="100%" />
<ControlStyle height="100px" />
</asp:Boundfield>
protected void gvAboutUs_RowEditing(object sender, GridViewEditEventArgs e)
aspx.cs
{
gvAboutUs.EditIndex = e.NewEditIndex;
bind();
}
LINK TO PICTURE OF TEXTBOX
It can be done with a TemplateField:
<asp:TemplateField>
<ItemTemplate>
<asp:Label runat="server" Text='<%# Eval("AboutUs_Text") %>' ... />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" Rows="4" TextMode="MultiLine" Text='<%# Eval("AboutUs_Text") %>' ... />
</EditItemTemplate>
</asp:TemplateField>

make Row in gridview asp.net clickable?

I create gridview and remove the select button to make all row clickable but I want to redirect the user for selected item detail
Note: I remover the CommandField select Visible="False"
int rowCount = 0;
protected void gv_TasksProjectForUser_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//var taskID = gv_TasksProjectForUser.SelectedDataKey.Value;
e.Row.Attributes.Add("onclick", "location='TaskDetail.aspx?taskID=" + e.Row.RowIndex + "'");
e.Row.Attributes.Add("onmouseover", "JavaScript:this.style.cursor='pointer';");
}
rowCount++;
}
I have made this with Item Templates.
What you have to do is remove the property AutogenerateColums and add them manually with objects and item templates, on those add one that could be a button.
Later on the code Behind add a event to handle the button click, on that event you can do the response.redirect to another page.
<asp:GridView ID="userGrid" runat="server" CssClass="AdminGrid"
AllowPaging="True" AutoGenerateColumns="False" PageSize="11">
<Columns>
<asp:BoundField DataField="ApplicationId" Visible="False" />
<asp:BoundField DataField="UserName" Visible="False" />
<asp:TemplateField >
<HeaderTemplate>
<asp:Label ID="lblEmail" Text="E-Mail" runat="server" CssClass = "HeaderLabel" meta:resourcekey="lblEmail"></asp:Label>
<asp:ImageButton ID="imgSortEMail" runat="server" ImageUrl="~/Images/normal.gif" OnClick="SortGrid" CommandArgument="EMail" CssClass="SortButton" ToolTip="Click here to Order" />
</HeaderTemplate>
<ItemTemplate>
<asp:HyperLink ID="lnkEMail" runat="server" CssClass="EmailLinkButton" Text='<%# FormatGridTextDisplay(DataBinder.Eval(Container.DataItem, "EMail")) %>' ToolTip='<%# DataBinder.Eval(Container.DataItem, "EMail") %>' NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "EMail","mailto:{0}") %>' ></asp:HyperLink>
</ItemTemplate>
<HeaderStyle CssClass="OverFlowStringField" />
<ItemStyle CssClass="OverFlowLeftAligned" />
</asp:TemplateField>
<asp:TemplateField >
<HeaderTemplate>
<asp:Label ID="lblSalonUser" Text="Salon User" runat="server" CssClass = "HeaderLabel" meta:resourcekey="lblSalonUser"></asp:Label>
<asp:ImageButton ID="imgSortIsSalonUser" runat="server" ImageUrl="~/Images/normal.gif" OnClick="SortGrid" CommandArgument="IsSalonUser" CssClass="SortButton" ToolTip="Click here to Order" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSalonUser" runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "IsSalonUser") %>' onclick="javascript:if (this.checked==true) this.checked=false; else this.checked=true;"/>
</ItemTemplate>
<HeaderStyle CssClass="OverFlowStringField" />
<ItemStyle CssClass="CenterAligned" />
</asp:TemplateField>
<asp:TemplateField >
<ItemTemplate>
<asp:Button ID="btnEdit" runat="server" Text="Editar" CssClass="GridButton" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "UserName")%> ' OnClick="btnEdit_Click" meta:resourcekey="btnEdit"/>
</ItemTemplate>
<HeaderStyle CssClass="OverFlowStringField" />
<ItemStyle CssClass="CenterAligned" />
</asp:TemplateField>
</Columns>
</asp:GridView>
There You can see that i add a few types of items template, the most important is the btnEdit, on that one there are 2 important properies, one is the CommandArgument where you send the values to redirect to the page and the other is the event OnClick that is the one that will handle the click for the button.
Protected void btnEdit_Click(Object sender , System.EventArgs e ){
Button clickedButton = (sender)Button;
String() argumentsSend = clickedButton.CommandArgument.ToString().Split("|");
String backParameters;
Response.Redirect(String.Concat("RedirectPage.aspx?user=", Server.UrlEncode(argumentsSend(0)), "&company=", Server.UrlEncode(argumentsSend(1)), True);
}
I took this code from VB and change it to c# with a compiler, it may have errors, but that's the idea.
A easyest way is to use a link button or an hipperlink on the template of the grid, that eay you may no need to go to the code file.

Categories