Procedure
…….
CREATEProcedure
GetoneRowonGridBydefault1
---@RecId bigint
as
---Ram Vinay Singh 5 November
2012
begin
if ((selectCOUNT(*)from
DripInterval1)=0)
Select
RecId=0,DripStart=0 ,DripEnd =0
union
Select
RecId,DripStart,DripEnd
from DripInterval1 Where active=1
else
Select
RecId,DripStart,DripEnd
from DripInterval1 Where active=1
end
HTML
Code……….For Grid Code..
<div>
<tableclass="style1">
<tr>
<tdbgcolor="#FFFFCC"style="font-size: xx-large; color:
#800080">
Admin Master </td>
</tr>
<tr>
<td>
<center>
<asp:GridViewID="GridView1"runat="server"ShowFooter="true"BackColor="LightGoldenrodYellow"
BorderColor="Tan"BorderWidth="1px"CellPadding="2"DataKeyNames="Recid"ForeColor="Black"
GridLines="None"AutoGenerateColumns=false
onrowediting="GridView1_RowEditing"onrowupdating="GridView1_RowUpdating"
onrowcommand="GridView1_RowCommand"
onrowcancelingedit="GridView1_RowCancelingEdit"onrowdeleting="GridView1_RowDeleting"
>
<AlternatingRowStyleBackColor="PaleGoldenrod"/>
<FooterStyleBackColor="Tan"/>
<HeaderStyleBackColor="Tan"Font-Bold="True"/>
<PagerStyleBackColor="PaleGoldenrod"ForeColor="DarkSlateBlue"
HorizontalAlign="Center"/>
<SelectedRowStyleBackColor="DarkSlateBlue"ForeColor="GhostWhite"/>
<SortedAscendingCellStyleBackColor="#FAFAE7"/>
<SortedAscendingHeaderStyleBackColor="#DAC09E"/>
<SortedDescendingCellStyleBackColor="#E1DB9C"/>
<SortedDescendingHeaderStyleBackColor="#C2A47B"/>
<Columns>
<asp:TemplateField>
<EditItemTemplate>
<asp:ImageButtonID="imgbtnUpdate"runat="server"CommandName="Update"
Height="20px"ImageUrl="Img/update.jpg"ToolTip="Update"Width="20px"/>
<asp:ImageButtonID="imgbtnCancel"runat="server"CommandName="Cancel"
Height="20px"ImageUrl="Img/Cancel.jpg"ToolTip="Cancel"Width="20px"/>
</EditItemTemplate>
<ItemTemplate>
<asp:ImageButtonID="imgbtnEdit"runat="server"CommandName="Edit"
Height="20px"ImageUrl="Img/Edit.jpg"ToolTip="Edit"Width="20px"/>
<asp:ImageButtonID="imgbtnDelete"runat="server"CommandName="Delete"
Height="20px"ImageUrl="Img/delete.jpg"Text="Edit"ToolTip="Delete"
Width="20px"/>
</ItemTemplate>
<FooterTemplate>
<asp:ImageButtonID="imgbtnAdd"runat="server"CommandName="Admin"
Height="30px"ImageUrl="Img/AddNewitem.jpg"ToolTip="Add new User"
ValidationGroup="validaiton"Width="30px"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateFieldHeaderText="Start
Trip">
<ItemTemplate>
<asp:LabelID="lvlStrip"runat="server"Text='<%#Eval("TripStart") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBoxID="TextBox1"runat="server"Text='<%#Eval("TripStart") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBoxID="txtST"runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateFieldHeaderText="TripEnd">
<ItemTemplate>
<asp:LabelID="Label1"runat="server"Text='<%#Eval("TripEnd")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBoxID="TextBox2"runat="server"Text='<%#Eval("TripEnd") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBoxID="txtET"runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateFieldHeaderText="Recid"Visible="false">
<EditItemTemplate>
<asp:TextBoxID="txtRecid"runat="server"Text='<%# Bind("Recid") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:LabelID="lbrRecid"runat="server"Text='<%# Bind("Recid") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</center>
</td>
</tr>
<tr>
<td>
<center>
<asp:LabelID="Label2"runat="server"Font-Bold="True"ForeColor="#CC0066"></asp:Label>
</center>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</div>
How to Bind
Grid view………….
publicvoid BindData()
{
string str;
DataSet ds = newDataSet();
ds =
GetRecordTripDetail();
string id = ds.Tables[0].Rows[0]["DripEnd"].ToString();
if (id == "0")
{
GridView1.DataSource = ds;
GridView1.DataBind();
GridView1.Rows[0].Visible
= false;
TextBoxtxtCopies = (TextBox)GridView1.FooterRow.FindControl("txtST");
TextBoxtxtDescription = (TextBox)GridView1.FooterRow.FindControl("txtET");
txtCopies.Text
= "0";
txtCopies.ReadOnly
= true;
}
else
{
GridView1.DataSource = ds;
GridView1.DataBind();
DataSetdslast = newDataSet();
dslast
= getlastId();
TextBox txt = (TextBox)GridView1.FooterRow.FindControl("txtST");
TextBox txt1 = (TextBox)GridView1.FooterRow.FindControl("txtET");
string str11;
str11 = dslast.Tables[0].Rows[0]["DripEnd"].ToString();
txt.ReadOnly
= true;
txt.Text
= str11;
txt1.Text = "";
}
}