SelectDataKey in GridView - c#

How do I grab the value from the SelectedDataKey function from the ButtonField? It keeps coming back null. Right now I've managed to create a foreach loop to actually see what value are available but this method is not ideal.
This is the ASP code
<asp:GridView ID="GridViewResults" AutoGenerateColumns="False" runat="server" HorizontalAlign="Center" CellPadding="10" CellSpacing="10" Width="1100px" SelectedRow="hotelId" GridLines="Horizontal" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" ForeColor="Black" DataKeyNames="hotelId" OnRowCommand="GridViewResults_RowCommand" >
<Columns>
<asp:ImageField DataImageUrlField="thumbNailUrl" DataImageUrlFormatString="https://media.expedia.com{0}" HeaderText="Image" />
<asp:BoundField DataField="name" HeaderText="Hotel Name" />
<asp:BoundField DataField="locationDescription" HeaderText="Location" />
<asp:BoundField DataField="hotelRating" DataFormatString="{0}/5" HeaderText="Hotel Rating" />
<asp:BoundField DataField="lowRate" DataFormatString="£{0}" HeaderText="Lowest Price" />
<asp:ButtonField Text="View" DataTextField="hotelId" HeaderText="View Hotel" ButtonType="Button" DataTextFormatString="{0}" />
<%-- <asp:HyperLinkField DataNavigateUrlFields="hotelId" HeaderText="View Hotel" DataNavigateUrlFormatString="http://api.ean.com/ean-services/rs/hotel/v3/info?apikey=5qjdrl3pjpj8f8gj6u7b40ofjk&sig=117f9d785e142c4be4285799ab8608b4&cid=488640&minorRev=99&customerUserAgent=Mozilla%2F5.0&customerIpAddress=84.246.168.11&locale=en_US&currencyCode=GBP&hotelId={0}" Text="View" />--%>
</Columns>
</asp:GridView>
This is the logic for the for each loop, but I want to grab the value which has been selected.
protected void GridViewResults_RowCommand(object sender, GridViewCommandEventArgs e)
{
foreach (GridViewRow row in GridViewResults.Rows)
{
string _hotelId = GridViewResults.DataKeys[row.RowIndex].Value.ToString();
var searchListRequest = new RestRequest("/ean-services/rs/hotel/v3/info", Method.GET);
string hotelId = _hotelId;
}
}

Add CommandName="hotelId" in your ButtonField and inside your GridViewResults_RowCommand do the following.
protected void GridViewResults_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "hotelId")
{
int rowindex = Convert.ToInt32(e.CommandArgument);
int hotelId = Convert.ToInt32(GridViewResults.DataKeys[rowindex].Value);
}
}
Hope it helps.
Regards!

Related

Asp Gridview Edit columns issue : Checkbox does not update columns

I am fairly new to Asp.Net. I have been trying to Edit a column value in a gridview but upon checking one of the two checkboxes (Yes or No), it does not update anything.
Sharing Gridview code below :
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#000000" BorderStyle="Solid"
BorderWidth="2px" CellPadding="6" DataKeyNames="film_data" DataSourceID="SqlDataSource" ForeColor="White"
GridLines="Vertical" onrowdatabound="GridView1_RowDataBound" AllowSorting="True">
<AlternatingRowStyle BackColor="#CCCCC" />
<Columns>
<asp:CommandField ShowEditButton="True">
<ControlStyle ForeColor="Blue" />
</asp:CommandField>
<asp:BoundField DataField="film_title" HeaderText="MOVIE TITLE" ReadOnly="True" SortExpression="film_title" >
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="film_release" HeaderText="RELEASE DATE" ReadOnly="True" SortExpression="release_date" >
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:CheckboxField DataField="Yes" HeaderText="YES" SortExpression="Yes" />
<asp:CheckboxField DataField="No" HeaderText="NO" SortExpression="No" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle />
</asp:GridView>
This is the GridView1_RowDataBound snippet from .cs file.
public void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//Checking the RowType of the Row
if (e.Row.RowType == DataControlRowType.DataRow)
{
....
What am I missing here ? Upon clicking Edit, and the Yes or No checkboxes. nothing gets updated. There is no error either. Kindly assist.
In Gridview change the commandfield and checkbox control like this in your code
<asp:TemplateField HeaderText="Yes/No">
<ItemTemplate>
<asp:Literal ID="ltrchkboxVal" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "chkboxval").ToString() %>'></asp:Literal>
</ItemTemplate>
<EditItemTemplate>
<asp:HiddenField ID="hdnchkboxval" runat="server" Value='<%# DataBinder.Eval(Container.DataItem, "chkboxval").ToString() %>'/>
<asp:CheckboxList ID="chkyesboxval" runat="server" Width="40">
<asp:ListItem> Yes</asp:ListItem>
<asp:ListItem> No</asp:ListItem>
</asp:CheckboxList >
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Button" CancelText="Cancel" ControlStyle-CssClass="small"
EditText="Optimise" HeaderText="Optimise" ShowEditButton="true" UpdateText="Apply" ItemStyle-Width="30px">
</asp:CommandField>
IN c# code
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
DivMessage.Visible = false;
GridView1.EditIndex = e.NewEditIndex;
//Bind gridview
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string yesnoval = (GridView1.Rows[e.RowIndex].FindControl("chkyesboxval") as CheckBoxList).SelectedItem.Value;
// update new values and Bind gridview
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
//Bind gridview
}
Add events for the gridview control
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating"

how to get data from a gridview

I display customers past orders in a gridview. They can press the Resend button in the last column to resend their order under the condition that the order is paid or past that status.
First the gridview:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="White" pagesize="10"
BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDataSource1" EmptyDataText="You have no orders yet"
GridLines="Vertical" OnRowCommand="GridView1_RowCommand">
<AlternatingRowStyle BackColor="#DCDCDC"/>
<Columns>
<asp:BoundField DataField="TD_OrdID" HeaderText="Ord" InsertVisible="False" ReadOnly="True" SortExpression="TD_OrdID" />
<asp:BoundField DataField="TD_OrdDate" DataFormatString="{0:d}" ItemStyle-HorizontalAlign="Right" HeaderText="Date" SortExpression="TD_OrdDate" ><ItemStyle HorizontalAlign="Right"></ItemStyle></asp:BoundField>
<asp:BoundField DataField="TD_PD_PackageName" HeaderText="Package Name" ItemStyle-HorizontalAlign="Left" SortExpression="TD_PD_PackageName" > </asp:BoundField>
<asp:BoundField DataField="TD_OSName" ItemStyle-HorizontalAlign="Right" HeaderText="Status" SortExpression="TD_OSName" > <ItemStyle HorizontalAlign="Right"></ItemStyle></asp:BoundField>
<asp:BoundField DataField="TD_InvID" HeaderText="Inv" InsertVisible="False" ReadOnly="True" SortExpression="TD_InvID" />
<asp:BoundField DataField="TD_InvPaid" HeaderText="Paid" ItemStyle-HorizontalAlign="Right" SortExpression="TD_InvPaid" ><ItemStyle HorizontalAlign="Right"></ItemStyle></asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat="server" ID="btnResend" CommandName="Resend" Text="Resend" CommandArgument="<% ((GridViewRow) Container).RowIndex
%>" OnDataBinding="btnResend_DataBinding" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" Font-Size="Small" HorizontalAlign="Center"/>
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView>
now the databinding to select the resend button when customer paid the order:
protected void btnResend_DataBinding(object sender, EventArgs e)
{
// only set button to enable when customer can resend document!
Button btn = (Button)(sender);
// enable button for status emailed, paid and closed
btn.Enabled = ((Eval("TD_OSName").ToString().Equals("closed")) ||
(Eval("TD_OSName").ToString().Equals("paid")) ||
(Eval("TD_OSName").ToString().Equals("emailed")));
}
which works fine. I am disabling the button. Maybe a better solution is to hide it instead. However this is not my concern.
now the row command to get the "ordId" value from the row where the button is pressed:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Resend")
{
// Retrieve the row index stored in the
// CommandArgument Property
int index = Convert.ToInt32(e.CommandArgument);
// Retrieve the row that contains the button
// from Rows collection.
GridViewRow row = GridView1.Rows[index];
// add code
int ordId = Convert.ToInt32(row.Cells[0].Text);
lblMessage.ForeColor = System.Drawing.Color.Green;
//lblMessage.Text = displayMessages.YourDocumentResent() + "OrdID:" + ordId;
//lblMessage.Text = displayMessages.YourDocumentResent();
lblMessage.Text = Convert.ToString(e.CommandArgument);
}
}
However to get the selected row and reading out the order identification from the row is challenging for me. I goggled this over and over and can’t see where I make the mistake.
The line:
int index = Convert.ToInt32(e.CommandArgument)
fails with
Input string was not in a correct format
If found this even on the msdn page of Microsoft?!
If I display the e.commandArgument I see: <% ((GridViewRow) Container).RowIndex %>
Can anyone help so I can get the value OrdId from TD_OrdID from the row the customer has pressed the Resend button?
Thank you in advance.
<% ((GridViewRow) Container).RowIndex %>
You're missing the #.
Try:
<%# ((GridViewRow) Container).RowIndex %>

Disable a buttonfield for a particular user in a gridview

This might get a little confusing but I will try my best to explain and would appreciate any help.I have a gridview like
<asp:GridView ID="GridView1" runat="server" Width="936px" AllowPaging="True" AutoGenerateColumns="False" CellPadding="3" DataSourceID="SqlDataSource1" OnRowCommand="GridView1_RowCommand" style="text-align: center" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellSpacing="2" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="TaskId" HeaderText="TaskId" InsertVisible="False" ReadOnly="True" SortExpression="TaskId" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Body" HeaderText="Body" SortExpression="Body" Visible="false" />
<asp:BoundField DataField="Reward" HeaderText="Reward(Rs)" SortExpression="Reward" />
<asp:BoundField DataField="TimeAllotted" HeaderText="Time(Min)" SortExpression="TimeAllotted" />
<asp:BoundField DataField="PosterName" HeaderText="Uploader" SortExpression="PosterName" />
<asp:ButtonField ButtonType="Button" CommandName="Select" Text="Perform Task" ControlStyle-ForeColor="White" ControlStyle-Font-Bold="true">
<ControlStyle BackColor="#CC6600" Font-Bold="True" ForeColor="White"></ControlStyle>
</asp:ButtonField>
</Columns>
When I click on the buttonfield of a particular row, I get directed to a new page which asks me to perform some task.
I want to disable the 'perform task' buttonfield for that particular user whenever a task is performed.
How can I do that?
Try this code:
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound" ...>
Other settings
</asp:GridView>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
var button = (Button) e.Row.Cells[e.Row.Cells.Count - 1].Controls[0];
button.Enabled = CanCurrentUserViewButton();
}
}
private bool CanCurrentUserViewButton()
{
//Logic...
}

Store many Values In single variable and session that variable to next page and convert into string

This Is my Gridview (sorry image not been uploading on stackExchange).
Headertext(ProductID | Image | Price | Stock | LinkButton(name =ADDtocart)
when user click add to cart button corresponding product id will got from using
asp html code :-
<asp:Content ID="Content1" ContentPlaceHolderID="main" runat="server" >
<asp:GridView ID="GridView3" DataKeyNames="ProductId" OnPageIndexChanging="GridView1_PageIndexChanged" AllowSorting="True" AllowPaging="True" PageSize="5" runat="server" CellPadding="4" EnableModelValidation="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" GridLines="Vertical" PagerStyle-HorizontalAlign="Center" Height="700px" Width="800px" ForeColor="Black" >
<Columns>
<asp:BoundField DataField="ProductId" HeaderText="ProductID" />
<asp:ImageField DataImageUrlField="ProductImage" HeaderText="ProductImage" AlternateText="Image Not Found" ControlStyle-Height="150px" ControlStyle-Width="150px" >
<ControlStyle Height="150px" Width="150px"></ControlStyle>
<FooterStyle Height="30px" Width="30px" />
<ItemStyle BorderStyle="None" BorderWidth="1px" Height="30px" Width="30px" Wrap="False" />
</asp:ImageField>
<asp:BoundField DataField="ModelName" HeaderText="ModelName" >
<ControlStyle Width="30px" />
</asp:BoundField>
<asp:BoundField DataField="Brand" HeaderText="Brand" />
<asp:BoundField DataField="Stock" HeaderText="Stock" />
<asp:BoundField DataField="Price" HeaderText="Price" />
<asp:TemplateField HeaderText="Click Button To Buy">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Add To Cart</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<script>
function myFunction() {
alert("Please Login\n New User Click SignUp Button on Top");
}
</script>
</asp:Content>
Button Event Code
protected void LinkButton1_Click(object sender, EventArgs e)
{
GridViewRow gr = ((sender as LinkButton).NamingContainer as GridViewRow);
string s = gr.Cells[0].Text.Trim();
}
My problem is when user click addtocart
string s store one productid value but i need to store multiple productid example like this(9,10,14) and session that value to nextpage for shoppingcart,
string s;
protected void LinkButton1_Click(object sender, EventArgs e)
{
GridViewRow gr = ((sender as LinkButton).NamingContainer as GridViewRow);
//string s = gr.Cells[0].Text.Trim();
s += gr.Cells[0].Text.Trim() + ";";
}

How to get a e.CommandArgument from a row in a gridview while using a dropdownlist inside it in asp.net c#?

recently I asked a similar question, which you can find in the link below
Using Dropdownlist in a gridview Asp.Net?
I have a gridview that looks like this...
<asp:GridView ID="grdvEventosVendedor" runat="server" AllowPaging="True"
AutoGenerateColumns="False" CellPadding="4" DatakeyNames="idCita"
EmptyDataText="No Hay Eventos Para Este Vendedor" ForeColor="#333333"
GridLines="None" AllowSorting="True"
onpageindexchanging="grdvEventosVendedor_PageIndexChanging"
onrowcommand="grdvEventosVendedor_RowCommand"
onsorting="grdvEventosVendedor_Sorting" CellSpacing="1"
onrowdatabound="grdvEventosVendedor_RowDataBound" >
<AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
<Columns>
<asp:TemplateField HeaderText="" ItemStyle-Width="35px">
<ItemTemplate>
<asp:ImageButton ID="imgBtnEdicEvento" runat="server"
CommandArgument='<%# Eval("idCita")%>' CommandName="Edicion"
Height="32px" ImageUrl="~/img/pencil_32.png" Width="32px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="" ItemStyle-Width="35px">
<ItemTemplate>
<asp:ImageButton ID="imgBtnDelete" runat="server"
CommandName="Borrar"
ImageUrl="~/img/1385_Disable_16x16_72.png"
onclientclick="return confirm('¿Desea eliminar el registro?');"
CommandArgument='<%# Eval("idCita")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Cliente" HeaderText="Cliente" InsertVisible="False" ReadOnly="True" SortExpression="Cliente" ItemStyle-Width="50px" />
<asp:BoundField DataField="Empresa" HeaderText="Empresa" InsertVisible="False" ReadOnly="True" SortExpression="Empresa" ItemStyle-Width="50px"/>
<asp:BoundField DataField="Telefono" HeaderText="Telefono" InsertVisible="False" ReadOnly="True" SortExpression="Telefono" ItemStyle-Width="50px"/>
<asp:BoundField DataField="Nextel" HeaderText="Nextel" InsertVisible="False" ReadOnly="True" SortExpression="Nextel" ItemStyle-Width="50px"/>
<asp:BoundField DataField="Tipo" HeaderText="Tipo" InsertVisible="False" ReadOnly="True" SortExpression="Tipo" ItemStyle-Width="50px"/>
<asp:BoundField DataField="Descripcion" HeaderText="Descripcion" InsertVisible="False" ReadOnly="True" SortExpression="Descripcion" ItemStyle-Width="100px"/>
<asp:TemplateField HeaderText="Fecha" SortExpression="Fecha" ItemStyle-Width="50px">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Fecha", "{0:dd/MM/yyyy}")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbxFecha" runat="server" Text='<%#Bind("Fecha","{0:dd/MM/yyyy}") %>' ValidationGroup="gpEdicionAgenda">
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="HoraInicio" HeaderText="Hora" InsertVisible="False" ReadOnly="True" SortExpression="HoraInicio" ItemStyle-Width="50px"/>
<asp:BoundField DataField="Lugar" HeaderText="Lugar" InsertVisible="False" ReadOnly="True" SortExpression="Lugar" ItemStyle-Width="50px"/>
<%--<asp:BoundField DataField="Estado" HeaderText="Estado" InsertVisible="False" ReadOnly="True" SortExpression="Estado" ItemStyle-Width="50px"/>--%>
<asp:TemplateField HeaderText="Estado" ItemStyle-Width="50px">
<ItemTemplate>
<asp:DropDownList ID="dpdListEstado" runat="server" OnSelectedIndexChanged="dpdListEstado_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem>Pendiente</asp:ListItem>
<asp:ListItem>Atendido</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CRM" ItemStyle-Width="25px">
<ItemTemplate>
<asp:ImageButton ID="imgBtnCRM" runat="server"
CommandArgument='<%# Eval("IdCliente")%>' CommandName="CRM"
ImageUrl="~/img/activar.png" Width="16px" Height="16px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="VM" ItemStyle-Width="25px">
<ItemTemplate>
<asp:ImageButton ID="imgBtnVerMas" runat="server"
CommandArgument='<%# Eval("IdCliente")%>' CommandName="VerMas"
ImageUrl="~/img/search.png" Width="16px" Height="16px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" Font-Size="Small" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" Font-Size="Larger" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Center" Font-Size="Small" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
As mentioned in the link, I had to manually add some code, like OnSelectedIndexChanged="dpdListEstado_SelectedIndexChanged" AutoPostBack="True" and also add this on the cs file...
protected void dpdListEstado_SelectedIndexChanged(object sender, EventArgs e)
{
}
I have tried it and it did work, whenever I change the value of a ddl, it does enter to the void int the cs file...
however now I have a question...
I need the Id from the record that it's stored in a specific row (idCita, as in the buttons I have which use a CommandArgument)... that way can use another class I have which would trigger a query that would edit a field called Estado....
However, I noticed that when I use CommandArguments, I use another void called...
protected void grdvEventosVendedor_RowCommand(object sender, GridViewCommandEventArgs e)
{
int intIdCita = int.Parse(e.CommandArgument.ToString());
if (e.CommandName == "Edicion")
{
//Some Code
}
else if (e.CommandName == "Borrar")
{
//More Code
}
else if (e.CommandName == "CRM")
{
//Even More Code
}
else if (e.CommandName == "VerMas")
{
//....
}
}
with this I can call both e.CommandName which tells me which button I pressed, and e.CommandArgument which is the value for idCita... however I noticed that the ddl void that I previously showed you doesnt have a GridViewCommandEventArgs e, instead it has a EventArgs e...
Is there a way that I can get the value of idCita from the gridview, all the way to the ddl void??
What do I need to add in the gridview code and in the cs file??
Thanks
Refactor you're code something like this - it should get you most of the way there, additionally look at converting the else if statements to a more readable switch case statement...
protected void dpdListEstado_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow gvr = (GridViewRow)(((Control)sender).NamingContainer);
MeaningfulNameHere(int.Parse(grdvEventosVendedor.DataKeys[gvr.RowIndex]),"Estado");
}
protected void grdvEventosVendedor_RowCommand(object sender, GridViewCommandEventArgs e)
{
MeaningfulNameHere(int.Parse(e.CommandArgument.ToString()),e.CommandName);
}
private void MeaningfulNameHere(int id, string commandName)
{
if (commandName == "Edicion")
{
//Some Code
}
else if (commandName == "Borrar")
{
//More Code
}
else if (commandName == "CRM")
{
//Even More Code
}
else if (commandName == "VerMas")
{
//....
}
else if (commandName == "Estado")
{
}
}

Categories